I created a VM with Windows Server 2019 Datacenter image in Azure. Due to company policy, we are not allow to have a public IP and port. The only way to access the VM is using the Serial Console.
I was able to run PowerShell in serial console. However, I got the access problem.
Error:
PS C:\windows\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
Enable-WindowsOptionalFeature : Win32 internal error "Access is denied" 0x5
occurred while reading the console output buffer. Contact Microsoft Customer
Support Services.
At line:1 char:1
+ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (:) [Enable-WindowsOptionalFeature],
HostException
+ FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.Dism.Commands.Enable
WindowsOptionalFeatureCommand
I tried to elevate the Powershell prompt, but no luck. The account I created should have admin access. I wonder there is any way I can get this working. Thanks in advance.
I believe there is some limitation on the Server 2019 Datacenter image because I also get the same error but it worked on the Server 2016 datacenter refer to this.
As a workaround, If the Azure VM does not have a public IP address assigned, I suggesting run PowerShell scripts within the Azure VM via run command. The feature uses the virtual machine (VM) agent to run PowerShell scripts within an Azure Windows VM. For more information about running scripts in your Windows VM, you could refer to this document.
For example, you can enable hyper-v via PowerShell Scripts
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
Then Invoke the scripts via Invoke-AzVMRunCommand
cmdlet to run a PowerShell script on an Azure VM. The cmdlet expects the script referenced in the -ScriptPath
parameter to be local to where the cmdlet is being run.