I tried to enable PSRemoting on a Windows VM in Azure. While it worked for some time, since last week the script doesn´t work anymore.
I ran the script using the Custom Script Extension feature:
Set-AzureRmVMCustomScriptExtension -ResourceGroupName $ResourceGroupName -VMName $VMName -Name "EnableWinRM_HTTP0" -Location $vm.Location -StorageAccountName $storageaccountname -StorageAccountKey $key -FileName "ConfigureWinRM_HTTP1.ps1" -ContainerName "scripts" -RunFile "ConfigureWinRM_HTTP1.ps1" ConfigureWinRM_HTTP1.ps1 script is described below:
# Ensure PS remoting is enabled, although this is enabled by default for Azure VMs Enable-PSRemoting -Force # Create rule in Windows Firewall New-NetFirewallRule -Name "WinRM HTTP" -DisplayName "WinRM HTTP" -Enabled True -Profile Any -Action Allow -Direction Inbound -LocalPort 5985 -Protocol TCP # Run WinRM configuration on command line. $cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTP" cmd.exe /C $cmd The virtual machine is successfully created in the same script some lines before, but when this script is part is executed, I got the following error:
Set-AzureRmVMCustomScriptExtension : Long running operation failed with status 'Failed'. Additional Info:'VM has reported a failure when processing extension 'EnableWinRM_HTTP0'. Error message: "Finished executing command".' ErrorCode: VMExtensionProvisioningError ErrorMessage: VM has reported a failure when processing extension 'EnableWinRM_HTTP0'. Error message: "Finished executing command". StartTime: 29/11/2017 15:07:24 EndTime: 29/11/2017 15:08:14 OperationID: aa418b4a-76b4-4482-93eb-16b734009388 Status: Failed At C:\.....\SetupVM.ps1:107 char:2 + Set-AzureRmVMCustomScriptExtension -ResourceGroupName $ResourceGr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureRmVMCustomScriptExtension], ComputeCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.SetAzureVMCustomScriptExtensionCommand The monitor in the Azure Management Portal doesn´t show anything but the same error message.
Why it is not working?
C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension. That will hopefully show you more details of the error.