Solved

PSEXEC script command to force gpupdate on client PC at logon

Posted on 2011-03-10
8
1,644 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

23 Experts available now in Live!

Get 1:1 Help Now