Solved

PSEXEC script command to force gpupdate on client PC at logon

Posted on 2011-03-10
8
1,651 Views
Last Modified: 2012-05-11
I would like to add a line to my existing script to force a group policy update for my laptop users upon logon.  I have the PSEXEC tool in the root of my C: drive for all my laptop users.  What would the correct command and syntax be for this?

I believe this works in a batch file but need it to run in a script
c:\psexec.exe \\%comp_name% gpupdate.exe /force

Help is appreciated, thanks!
0
Comment
Question by:jmchristy
  • 4
  • 4
8 Comments
 
LVL 8

Accepted Solution

by:
jawa29 earned 250 total points
ID: 35096988
Hi jmchristy

You could just call it like this.

Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "gpupdate /force",,True

Jawa29

0
 

Author Comment

by:jmchristy
ID: 35097142
I'm getting a Line 25, Char 1, error Variable is undefined: oShell
code: 800A01F4

When I try to put that in the script
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35097306
You need to add it to the Dim if your script is set as option explicit.

Jawa29
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:jmchristy
ID: 35097356
Super, got it.
Anyway to hide that gpupdate screen as well?
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35098162
Add Const vbHide = 2 to the very top of your script then append the code as below.

oShell.Run "gpupdate /force", vbHide, True

Jawa29

0
 

Author Comment

by:jmchristy
ID: 35098659
Getting an error on Line 2 Char 1, expected statement

I put Const vbHide = 2 at the very top
0
 
LVL 8

Expert Comment

by:jawa29
ID: 35099205
Sorry, option explicit should be the first line then all your const sit under that.

Jawa29
0
 

Author Comment

by:jmchristy
ID: 35099266
Got it, works!  Thank you.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Synchronize a new Active Directory domain with an existing Office 365 tenant
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question