Azure Hybrid worker not seeing installed modules

%3CLINGO-SUB%20id%3D%22lingo-sub-2596429%22%20slang%3D%22en-US%22%3EAzure%20Hybrid%20worker%20not%20seeing%20installed%20modules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2596429%22%20slang%3D%22en-US%22%3E%3CP%3ESingle%20hybrid%20worker.%26nbsp%3B%20The%20automation%20account%20has%20the%20AzureAD%20module%20as%20well%20as%20Az.Storage%20and%20AzTable%20installed.%26nbsp%3B%20The%20hybrid%20worker%20has%20the%20same%20modules%20installed%2C%20same%20versions.%26nbsp%3B%20From%20the%20context%20of%20the%20hybrid%20worker%2C%20the%20modules%20work%20fine.%26nbsp%3B%20If%20I%20try%20to%20execute%20a%20runbook%20against%20the%20hybrid%20worker%20(saved%20and%20published)%20it%20says%20it%20cannot%20find%20AzureAD%20or%20AzTable%20modules.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20run%20Get-Module%20%5BAzureAD%7CAzTable%5D%20-List%20from%20the%20test%20pane%20nothing%20happens%20and%20it%20doesnt%20find%20the%20module.%26nbsp%3B%20If%20I%20run%20Get-Module%20Az.Table%20-List%20it%20shows%20the%20module.%26nbsp%3B%20I%20am%20not%20certain%20why%20these%20modules%20are%20not%20showing%20up.%26nbsp%3B%20I%20rebooted%2C%20waited%20and%20still%20not%20working.%26nbsp%3B%20I%20havent%20seen%20this%20before.%26nbsp%3B%20When%20using%20the%20SharePoint%20and%20PnP%20modules%20they%20worked%20fine.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2596785%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Hybrid%20worker%20not%20seeing%20installed%20modules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2596785%22%20slang%3D%22en-US%22%3EDid%20you%20install%20those%20modules%20in%20the%20Hybrid%20Worker%20in%20an%20elevated%20prompt%3F%20By%20default%2C%20the%20hybrid%20worker%20job%20will%20execute%20in%20the%20Local%20System%20context.%20Therefore%2C%20PS%20modules%20must%20be%20installed%20system-wide.%20Can%20you%20check%20if%20the%20path%20C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%20contains%20the%20required%20modules%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2632409%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Hybrid%20worker%20not%20seeing%20installed%20modules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2632409%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%20thanks%20for%20the%20reply.%20I%20remoted%20into%20the%20server%20and%20ran%20GCI%20on%20that%20directory%20and%20I%20see%20it%20showing%20up%20yes.%20I%20also%20did%20install%20with%20an%20evelvated%20prompt.%20I%20just%20dont%20understand%20why%20its%20not%20seeing%20this%20module.%20I%20uninstalled%20and%20reinstalled%20still%20no%20luck.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22modules.jpg%22%20style%3D%22width%3A%20712px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F302183i9125737ACB26F862%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22modules.jpg%22%20alt%3D%22modules.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2633128%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Hybrid%20worker%20not%20seeing%20installed%20modules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2633128%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F453722%22%20target%3D%22_blank%22%3E%40hspinto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStill%20no%20luck%2C%20but%20I%20found%20a%20workaround%20for%20now.%26nbsp%3B%20Works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EFind-Module%20AzureADPreview%20%7C%20Save-Module%20-Path%20%24env%3ATEMP%20-Force%20-Confirm%3A%24false%0A%0A%24modulePath%20%3D%20Join-Path%20-Path%20%24env%3ATEMP%20-ChildPath%20%22AzureADPreview%22%0A%0AImport-Module%20%24modulePath%0A%0A%24cert%20%20%20%20%20%20%20%3D%20Get-AutomationCertificate%20-Name%20'cert'%0A%24ClientId%20%20%20%3D%20Get-AutomationVariable%20-Name%20'cid'%0A%24TenantID%20%20%20%3D%20Get-AutomationVariable%20-Name%20'tid'%0A%0AConnect-AzureAD%20-TenantId%20%24TenantID%20-ApplicationId%20%24ClientId%20-CertificateThumbprint%20%24cert.Thumbprint%0A%0AGet-AzureADUser%20-SearchString%20'jdoe'%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Single hybrid worker.  The automation account has the AzureAD module as well as Az.Storage and AzTable installed.  The hybrid worker has the same modules installed, same versions.  From the context of the hybrid worker, the modules work fine.  If I try to execute a runbook against the hybrid worker (saved and published) it says it cannot find AzureAD or AzTable modules. 

 

If I run Get-Module [AzureAD|AzTable] -List from the test pane nothing happens and it doesnt find the module.  If I run Get-Module Az.Table -List it shows the module.  I am not certain why these modules are not showing up.  I rebooted, waited and still not working.  I havent seen this before.  When using the SharePoint and PnP modules they worked fine.  

 

Thanks

3 Replies
Did you install those modules in the Hybrid Worker in an elevated prompt? By default, the hybrid worker job will execute in the Local System context. Therefore, PS modules must be installed system-wide. Can you check if the path C:\Program Files\WindowsPowerShell\Modules contains the required modules?

@hspinto 

 

Hi, thanks for the reply. I remoted into the server and ran GCI on that directory and I see it showing up yes. I also did install with an evelvated prompt. I just dont understand why its not seeing this module. I uninstalled and reinstalled still no luck.

 

modules.jpg

@hspinto 

 

Still no luck, but I found a workaround for now.  Works.

 

Find-Module AzureADPreview | Save-Module -Path $env:TEMP -Force -Confirm:$false

$modulePath = Join-Path -Path $env:TEMP -ChildPath "AzureADPreview"

Import-Module $modulePath

$cert       = Get-AutomationCertificate -Name 'cert'
$ClientId   = Get-AutomationVariable -Name 'cid'
$TenantID   = Get-AutomationVariable -Name 'tid'

Connect-AzureAD -TenantId $TenantID -ApplicationId $ClientId -CertificateThumbprint $cert.Thumbprint

Get-AzureADUser -SearchString 'jdoe'