Solved

PSEXEC script command to force gpupdate on client PC at logon

Posted on 2011-03-10
8
1,647 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
 

Author Comment

by:jmchristy
ID: 35097356
Super, got it.
Anyway to hide that gpupdate screen as well?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now