我想在远程站点上运行以下PowerShell命令
Get-CimInstance -ClassName Win32_OperatingSystem | select csname, lastbootuptime
和
Get-Counter -Counter "\memory\available mbytes" -MaxSamples 10 -SampleInterval 1
那是这样的调用命令格式吗?
Invoke-Command -ComputerName server01 {
Get-CimInstance -ClassName Win32_OperatingSystem | select csname, lastbootuptime
}
答案 0 :(得分:0)
如果在目标上设置了winRM,则可以从头开始在Get-CimInstance中传递ComputerName参数:
Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName server01| select csname, lastbootuptime
与Get-Counter相同:
Get-Counter -ComputerName server01 -Counter "\memory\available mbytes" -MaxSamples 10 -SampleInterval 1