對於管理員來說,有時候我們通過下列方法手動刷新組策略:
Windows XP系統:
Gpupdate.exe /Target:User /force --刷新用戶配置
Gpupdate.exe /Target:Computer /force --刷新計算機配置
windows 2000系統:
Secedit.exe /refreshpolicy user_policy --刷新用戶配置
Secedit.exe /refreshpolicy machine_policy --刷新計算機配置
這裏給出遠程批量刷新組策略的方法,用到的工具爲pstools中的Psexec.exe。關於psexec的詳細參數請參考其幫助文件。
對於 Windows XP:
Psexec.exe @ComputerList.txt Gpupdate.exe /Target:User /force
Psexec.exe @ComputerList.txt Gpupdate.exe /Target:Computer /force
對於Windows 2000:
Psexec.exe @ComputerList.txt secedit.exe /refreshpolicy user_policy
Psexec.exe @ComputerList.txt secedit.exe /refreshpolicy machine_policy
其中ComputerList.txt爲保存了計算機名稱的文本文件,每個計算機名佔一行。
對於擁有windows xp和windows 2000的混合環境,我們可以先通過腳步判斷其操作系統類型然後執行相應的遠程刷新命令。參考批處理如下:
@echo off
XPGPORef1=gpupdate.exe /Target:User /force
XPGPORef2=gpupdate.exe /Target:Computer /force
Win2kGPORef1=secedit.exe /refreshpolicy user_policy
Win2kGPORef2=secedit.exe /refreshpolicy machine_policy
For /f “Tokens=*” %%a in (ComputerList.txt) Do (
SET Comp_name=%%a
Ver.exe \\%comp_name% > Hostver.txt
Find /I “XP” < Hostver.txt > CheckCC.txt
IF %errorlevel% == 0 (
Psexec.exe \\%comp_name% Gpupdate.exe /Target:User /force
Psexec.exe \\%comp_name% Gpupdate.exe /Target:Computer /force
) ELSE (
Psexec.exe \\%comp_name% secedit.exe /refreshpolicy user_policy
Psexec.exe \\%comp_name% secedit.exe /refreshpolicy machine_policy
)
參考文獻微軟KB556027