要远程使用 gpupdate.exe ,你可以看下这样一个脚本:
function Start-GPUpdate
{
param
(
[String[]]
$ComputerName
)
$code = {
$rv = 1 | Select-Object -Property ComputerName, ExitCode
$null = gpupdate.exe /force
$rv.Exitcode = $LASTEXITCODE
$rv.ComputerName = $env:COMPUTERNAME
$rv
}
Invoke-Command -ScriptBlock $code -ComputerName $ComputerName |
Select-Object -Property ComputerName, ExitCode
}
函数Start-GPUpdate支持一个或多个电脑名且将让它们全部执行gpupdate.exe。其结果将会返回到你。
这个脚本利用了PS的远程优势,所以在目标电脑必须打开PS远程支持,且你还需要目标电脑的本地管理员权限。
原文地址:gpupdate on Remote Machines
本文链接: https://www.pstips.net/gpupdate-on-remote-machines.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
