MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.45k forks source link

Import-Module .\HybridRegistration.psd1 is not supported on Powershell 7 #66275

Closed flarsmar closed 3 years ago

flarsmar commented 3 years ago

Step 2 on Manual Install (https://docs.microsoft.com/en-us/azure/automation/automation-windows-hrw-install#step-2---install-the-runbook-environment-and-connect-to-azure-automation)

Import-Module .\HybridRegistration.psd1 is not supported on Powershell 7 (Tested latest version 7.1) Import command fails with error: Import-Module: Could not load type 'System.Web.HttpException' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Step 3 on Automatic Install (https://docs.microsoft.com/en-us/azure/automation/automation-windows-hrw-install#step-3---run-the-powershell-script)

Same as above, please specify that the script is only supported on PowerShell 5.1.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

KrishnaG-MSFT commented 3 years ago

@flarsmar Thanks for your comment! We will review and provide an update as appropriate.

KrishnaG-MSFT commented 3 years ago

@flarsmar Good catch! 👍 I was also able to reproduce the issue.

image

image

I will check with our internal team to understand if there is a current limitation on this feature and if required I will enhance the document as appropriate. Thanks again for the feedback!

MGoedtel commented 3 years ago

@flarsmar - The HybridRegistration script requires POSH WSF 5.1 and the article was wrong to suggest later versions of PowerShell were supported. From what I understand, the System.Web assembly is not supported in PowerShell core. I've updated the article accordingly to reflect this. My apologies for the confusion this has caused. I'm going to close this PR as I believe the issue has been properly addressed. If I did not properly address your feedback, please feel free to respond. #please-close.

AspenForester commented 1 year ago

This was true in 2020, and remains technically true, I've found that you can manually register the hybrid worker by importing the "HybridRegistration" module in PowerShell 7.x, using the -UseWindowsPowerShell switch parameter.

This could be applied to New-OnPremiseHybridWorker.ps1, too.