[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6589
  • Last Modified:

issues with a GPO that calls a powershell script

Hi Experts

I have a client who is enabling a new GPO that essentially calls a PowerShell script. We have tested manually the script, and it works very well.

It seems like the group policy is not working, however when you run the gpresult /r and gpupdate/force the policy is being applied. This result was verified from a WIndows 7 joined domain pc

The script basically renames old printers and printer name and add new printers with new server name for all users. I did download the script from link below
http://gallery.technet.microsoft.com/scriptcenter/PowerShell-Script-for-057ae37a

Like I mentioned earlier, the script works like a champion.
Please see  details of GPO on the attached files
Printer1.jpg
Printer2.jpg
Printer3.jpg
0
Jerry Seinfield
Asked:
Jerry Seinfield
  • 3
  • 2
  • 2
2 Solutions
 
Jerry SeinfieldAuthor Commented:
I did try using the format below with no luck
\\DOMAIN.COM\netlogon\TEST_PRINTER_MIGRATION.ps1

As additional note, our domain/forest functional level is Windows 2003.

Domain controllers OS. Windows 2003 R2
Print servers OS:  Windows 2008 R2

Can anyone please help me to find the root cause on why I cannot apply a GPO that looks pretty simple and basically calls a powershell script?

I did manually run the script from a WIndows 7 client and it worked
0
 
David Johnson, CD, MVPOwnerCommented:
ensure that it is run on the user level and not the machine level.
Powershell 
Data collected on: 25-Aug-2014 10:19:19 PM hide all 

The settings in this GPO can only apply to the following groups, users, and computers:Name 
NT AUTHORITY\Authenticated Users 
Computer Configuration (Enabled)hide
No settings defined.
User Configuration (Enabled)hide
For this GPO, Script order: Windows PowerShell scripts will run lastName Parameters 
get-computerrole.ps1  

Open in new window

LOCATION
\\techsupport4me.com\SysVol\techsupport4me.com\Policies\{8C97CF50-C8A6-44E1-8953-A11D82EA1D45}\User\Scripts\Logon
If you have a powershell scripts folder in group policy
you may have to call a batch file
%systemroot%\System32\Powershell.exe -executionpolicy remotesigned -File .\yourscriptname.ps1   -noprofile
0
 
footechCommented:
I believe the .PS1 script has to be applied from the PowerShell Scripts tab, or else it will just be opened with Notepad.  If you don't have that option (you might try managing GP from a Win7/2008R2 machine), then I think you will have to create a batch script to call the .PS1 script (as David mentioned), and call the batch script from GP.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Jerry SeinfieldAuthor Commented:
can you please provide an example of the batch script to be create to call the PST script? and the exact path where this batch must be placed?
0
 
footechCommented:
David provided the line.
%systemroot%\System32\Powershell.exe -executionpolicy remotesigned -File .\yourscriptname.ps1   -noprofile

The batch file will be the logon script, so will be under the Netlogon share.   You will want to have the .PS1 script saved in a share location that is reachable, and change the batch command above to reference the path to that .PS1 file.
0
 
David Johnson, CD, MVPOwnerCommented:
I thought I said:

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe

Open in new window

vs
%systemroot%\System32\Powershell.exe

Open in new window


The first one is correct and  the second one is wrong
0
 
footechCommented:
Good eye.  I didn't look to closely at the path.  You could also just reference powershell.exe without the full path, as it is included in the system path.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now