T_rey_S
May 30, 2023Copper Contributor
Invoke-Command does not return IIS Provider data
Taking it to the Community...
I want to retrieve IIS AppPool information from remote computers, and eventually update them.
As seen in the code snippet below, if the GCI for, the File System Provider, "C:\Temp", is enabled, the expected data are returned. However, The scriptBlock using the IIS: provider returns no data. It does generate an empty/null PSCusomObject.
The same GCI statement, "Get-ChildItem -Path 'IIS:AppPools' " returns expected data when run locally on a target computer.
What am I missing?
#Module does not load automatically in remote call.
$sbCmdL = { Import-Module WebAdministration
$colPoolsL = Get-ChildItem -Path 'IIS:AppPools'
}#End sb
#$sbCmdL = { Get-ChildItem -Path 'C:\Temp' }
$colPoolsL = Invoke-command -ComputerName $Server `
-ScriptBlock $sbCmdL `
-Credential $Credential `
-ErrorAction 'Stop'