我想在多台服务器上运行带有 WinRM 的 powershell。我正在使用带有脚本块的 Invoke-Command。
我正在从 IIS 读取并希望返回一个 AppPool-Object,但我无法访问它的属性 - 始终为空。
#--imagine this code in a foreach block
$result = Invoke-Command -ComputerName $line.Servername -ScriptBlock {
Import-Module WebAdministration
$remotePoolName = Get-Item "IIS:\Sites\LeSite" #| Select-Object applictionPool
$pool = dir IIS:\AppPools | Where-Object { $_.Name -eq $remotePoolName.applicationPool }
return $pool
}
write-host $result.managedRuntimeVersion <- empty
我是否必须在远程机器上访问它并将其作为字符串返回?