Get-Service 2. 获取名为“Network”的服务信息:Get-Service-Name Network 3. 获取显示名称为“网络连接”的服务信息:Get-Service-DisplayName "网络连接"4. 获取远程计算机上的服务信息(假设你知道远程计算机的名称或IP地址):Get-Service-ComputerName "RemoteCompute
Invoke-Command-ComputerNameServer02-ScriptBlock{Get-Service} 您也可以使用其他*-ServiceCmdlet 來管理服務。 如需PowerShell遠端的詳細資訊,請參閱about_Remote。 取得必要和相依服務 Get-Service Cmdlet 有兩個參數,在服務管理方面非常有用。 DependentServices 參數會取得相依於服務的服務。
Get-CimInstance-ClassNameWin32_Service|Select-Object-PropertyStatus,Name,DisplayName 输出 Status Name DisplayName --- --- --- OK AJRouter AllJoyn Router Service OK ALG Application Layer Gateway Service OK AppIDSvc Application Identity OK Appinfo Application Information OK AppMgmt Application Management ...
Invoke-Command-ComputerName"RemoteComputerName"-ScriptBlock{Start-Service-Name"ServiceName"} 通过Invoke-Command 可以在远程计算机上启动特定的服务。 远程关闭计算机: powershellCopy Code Invoke-Command-ComputerName"RemoteComputerName"-ScriptBlock{Stop-Computer-Force} ...
Get-Service Set-Service Get-WinEvent Get-WmiObject 通常情况下,支持无需特殊配置的远程处理的 cmdlet 具有 ComputerName 参数,但不具有 Session 参数。 若要在会话中查找这些 cmdlet,请键入: PowerShell Get-Command|Where-Object{$_.Parameters.Keys-contains"ComputerName"-and$_.Parameters.Keys-notcontains"Sess...
PS C:\Users\l00379637> Invoke-Command-ComputerName DESKTOP-NFBQJAR.china.huawei.com-Credential l00379637-ScriptBlock { Get-Service WinRM } Status Name DisplayName PSComputerName --- Running WinRM Windows Remote Management (WS-Manag... DESKTOP-NFBQJAR.china.huawei.com 恶意软件利用该命令: https...
Invoke-Command -ComputerName cd-lsr-svr -ScriptBlock { Get-Service WinRM } -credential $Cred 1. 2. 3. 4. 5. 远程执行多个命令 有时候我们需要连续执行多个有关联的命令,比如后一条命令会用到前一条命令的结果。此时再使用上面的方法就不行了。需要通过 session 来处理命令之间的联系: ...
Length;$i++){ "`$iparray["+$i+"]="+$iparray[$i]+"`n" Invoke-Command -ComputerName $iparray[$i] -Credential $Cred -ScriptBlock { Get-WindowsFeature -Name NET-*, Web-* | where {$_.Name -notmatch "Ftp|Web-Application-Proxy"} | Install-WindowsFeature; } }...
$HybridEndpoint = "finance1" $Script = { Param( [Parameter(Mandatory=$True)] [String] $Service ) Get-Service $Service } Write-Output "Scenario 1: Running command via Invoke-Command" Invoke-Command -ComputerName $HybridEndpoint ` -Credential $Credential ` -Port 5986 ` -UseSSL ` -ScriptBlo...
Get-Service Set-Service Get-WinEvent Get-WmiObject 通过以上的命令我们可以去操作主机的服务及进程等,例如可以去开启“WinRM”服务 例子1:远程重启计算机 使用“Restart-Computer”命令重启计算机,如果有用户登录的情况下,无法执行,可以加上“-Force”参数强制执行。