我想在我的脚本中执行关闭过程。我用Stop-Computer。但总是重启,不关机。我stop-computer单独尝试过,它有效,但是当我将它应用到我的脚本中时,它会重新启动,不会关闭,任何人都可以给出任何想法吗?
请参阅stop-computer,您可以使用它-Force来强制立即关闭计算机。
stop-computer -computername localhost -Force
Run Code Online (Sandbox Code Playgroud)
小智 1
如果您想关闭计算机Workgroup environment。
场景:您想要从名为 PC1 的计算机关闭名为 HP-ZBook 的计算机
步骤 1:在 PC1 上 => 启动 Powershelladmin mode
步骤2:在PC1上=>运行命令检查HP-ZBOOK是否在PC1的可信主机列表中
Get-Item WSMan:\localhost\Client\TrustedHosts
Run Code Online (Sandbox Code Playgroud)
步骤3:在PC1上运行命令将HP-ZBOOK添加到PC1的可信主机列表中
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'HP-ZBOOK'
Run Code Online (Sandbox Code Playgroud)
步骤 4:在 HP-ZBOOK 上 => 启动 powershelladmin mode
步骤 5:在 HP-ZBOOK 上运行以下命令启动 WinSRM 服务并启用 WinRM 防火墙例外
WinRM QuickConfig
Run Code Online (Sandbox Code Playgroud)
步骤 6:在 PC1 上运行命令关闭计算机 HP-ZBOOK
Stop-Computer -ComputerName HP-ZBook -force
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14048 次 |
| 最近记录: |