要远程使用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远程支持,且你还需要目标电脑的本地管理员权限。
×用微信扫描并分享