我需要运行以下内容:
Get-ChildItem Cert:\LocalMachine -Recurse
在远程计算机上。例如,我有一个循环:
foreach ($server in $serverList) {
if((Test-Connection -Cn $server -BufferSize 16 -Count 1 -ea 0 -quiet))
{
$certs = Get-ChildItem Cert:\LocalMachine -Recurse | Select Thumbnail, subject
.....
}
}
如何确保它在远程计算机上运行?
答案 0 :(得分:0)
您可以使用Invoke-Command
:
foreach ($server in $serverList) {
if((Test-Connection -Cn $server -BufferSize 16 -Count 1 -ea 0 -quiet))
{
$certs = Invoke-Command -Cn $server {
Get-ChildItem Cert:\LocalMachine -Recurse | Select Thumbnail, subject
}
.....
}
}