簡體   English   中英

如何使用Invoke-Command運行此PowerShell命令?

[英]How to run this PowerShell command with Invoke-Command?

我想在遠程站點上運行以下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
}

如果在目標服務器上設置了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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM