
Explanation:
< Run from: Azure Cloud Shell
Cmdlet: Enable-AzVMPSRemoting
In the Administering Windows Server Hybrid Core Infrastructure guidance for managin g Windows Server IaaS VMs, Microsoft specifies that when a newly deployed Windows Server VM in Azure is using default settings, WinRM (PowerShell Remoting) isn't opened by default in the NSG and the VM may not be configured for remoting. The prescribed met hod is to use Azure PowerShell to configure the VM from outside the VM . The module provides the purpose-built cmdlet Enable-AzVMPSRemoting , which
"configures WinRM on the target Windows VM, opens the required inbound ports in the attached network security group, and enables required firewall rules by using the Azure VM agent." Because you cannot yet remote to the VM to run Enable-PSRemoting , you must run the Azure cmdlet remotely -the study materials note that this can be executed from Azure Cloud Shell or a ny workstation with the Az PowerShell module.
Running it from Azure Cloud Shell minimizes local setup and uses your signed-in Azure context.
Therefore, to ensure you can connect to VM1 using PowerShell remoting, run Enable-AzVMPSRemoting from Azure Cloud S hell . Options like Enable-PSRemoting -Force or Enable-PSSessionConfiguration require executing on the VM itself , which isn't possible until remoting is already enabled.