Link to home
Start Free TrialLog in
Avatar of it-infra
it-infra

asked on

How to write a script and run it on Group Policy?

Hello All,

I'm running WSUS and for some reasons I wanna run the following:

1- Net Stop WUAUServ
2- Delete C:\Windows\SoftwareDistribution
3- Net Start WUAUServ

These 3 commands will stop updating service, delete updates that might be corrupted then restart the service, how to write such a script and how to implement it on Group Policy?


Thanks
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

1. Write your script and save it in your domain's SYSVOL\<domainname>\Scripts folder.
In ADUC create or edit a GPO.
2. Go to the Computer or User Configuration, depending on how you want your script to run.
3. Under Window Settings > Scripts you'll see StartUp and Shutdown (or Logon and Logoff).  Double-click the event you want and "Add..." the script
ASKER CERTIFIED SOLUTION
Avatar of Tony Massa
Tony Massa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
EE:
Do the numbers really have to be that big?  Screen HOG, sorry guys, first time I've tried that
Avatar of it-infra
it-infra

ASKER

@tmassa99

Will that work with earlier OS like XP? cuz I got this note:

"PowerShell scripts requires at least Windows 7 or Windows Server 2008."

However I found this article: http://social.technet.microsoft.com/Forums/en/winserverGP/thread/a8921d68-5115-448a-b489-16b941a971f6

So is the above script written to work on legacy OS too?

Thanks
This is a VBScript, so it will work on either
I modified the code to be a batch as follow:

net stop wuauserv
rd /s /q %windir%\SoftwareDistribution
net start wuauserv
%windir%\system32\wuauclt.exe /detectnow

Open in new window


I configured it to be on startup however I wanna do it only once on a specific time, is there a way to do it? Like I wanna run the script on 6 PM everyday.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial