powershell - Powershell Invoke-GPUpdate - “没有注销”可能吗?
问题描述
希望运行Invoke-GPUPdate -force
到一组远程计算机并以“否”响应注销提示。
试过:
Echo "n" | invoke-gpupdate
错误:Invoke-gpupdate 不接受管道输入
使用的命令:
Invoke-GPUpdate -Computer $computer -RandomDelayInMinutes 0 -force
解决方案
不幸的是,看起来这个 cmdlet 启动/安排了一次 gpupdate 运行,该运行最终单独发生(进程外),因此通过 PowerShell 处理此类事情的标准方法没有太多可做的,因为提示没有出现从 PowerShell 中。有一个-LogOff
参数,但它是一个开关参数,这意味着它的值仅用于注销。您可以这样尝试:-Logoff:$false
但很可能无法摆脱提示。
我认为您最好的机会不是使用此 cmdlet,而是直接使用Invoke-Command
with gpupdate.exe
:
Invoke-Command -ComputerName $computer -ScriptBlock {
echo nn | gpupdate.exe /force
}
但这需要在您要管理的计算机上启用 PowerShell 远程处理。
推荐阅读
- node.js - HTTP 发送后请求失败
- python - 用python从json中提取数据
- php - 是否有可能从这段代码中形成某种循环?
- java - jfreechart 在不同图表上绘制多个系列并合并为一个 jpg 文件
- node.js - 反向地理编码 NPM node.js
- sql-server - TSQL PIVOT 从 2 列从 1 到标题
- python - Tornado - 从等待中获取返回值(多个回调)
- python - 错误:经理不可用;'auth.User' 已在 Django 中替换为'Log.CUstomUser'
- java - ClassCastException 到同一个类
- jenkins - 使用 slackSend 的 Jenkins 管道评估步骤