azureautomation / runbooks

Sample Automation runbooks
MIT License
154 stars 129 forks source link

New-OnPremiseHybridWorker fails in PS 7 #69

Open jitterbox opened 3 years ago

jitterbox commented 3 years ago

Running New-OnPremiseHybridWorker in PowerShell 7 fails with the following error: Exception: C:\Users\theboss\Documents\PowerShell\Scripts\New-OnPremiseHybridWorker.ps1:385 Line | 385 | throw "The HybridRegistration module was not found. Please ensure … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The HybridRegistration module was not found. Please ensure the Microsoft Monitoring Agent was | correctly installed.

The failure seems to be on Import-Module .\HybridRegistration.psd1 ...which returns Import-Module: Could not load type 'System.Web.HttpException' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

This works in PowerShell 5.1, but I'm not able to run the full script in 5.1 because I need to retain the AzureRM module. I don't want to downgrade to PowerShell 6...

najki78 commented 1 week ago

Four years after @jitterbox raised the issue and it persists. Is there some workaround available please?