Solved

run a powershell script

Posted on 2012-04-05
3
695 Views
Last Modified: 2012-06-27
Hi don't know if this is possible but running a small domain and I have a powershell script to change a few permissions and delete a file and would like to push it out via group policy. So i created a new policy added the script as a startup script in the computer section and selected the GPO option to run powershell scripts as unrestricted. Problem is the script will still not run from GP (even though it runs fine when I right click it and select run with powershell form the network share). After a little research I have discovered this is because the script is still pausing and asking for permission to run and to overcome this I need to sign the script. I don't have a CA and it seems a little much to but a certificate and go though all that mess just to run a simple script. Is there a way around this issue that does not involve me going round every machine and running the script manually?
0
Comment
Question by:Dead_Eyes
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Dale Harris
ID: 37812569
Our workaround was to run a .bat file that runs a powershell script file with the appropriate executionpolicy.  Example:

@echo off
powershell.exe -windowstyle hidden -executionpolicy unrestricted "Scriptname.ps1"

Try that.
0
 

Author Comment

by:Dead_Eyes
ID: 37812626
Thanks for the fast reply, do you know if that would that work for:

@echo off
powershell.exe -windowstyle hidden -executionpolicy unrestricted "\\domian\netlgon\Scriptname.ps1"

and do need to change the exectionpolicy to unrestricted on the GPO or can i just leave it is restricted and the bat file will sort it out? (seems like a good security loophole if you can just use a bat file to change the execution policy lol)
0
 
LVL 16

Accepted Solution

by:
Dale Harris earned 500 total points
ID: 37812651
Yeah you're going to be able to easily run it from a domain location.  If there's an issue, you might have to specify -script and then the location.  Just do a "powershell.exe /?" in your powershell window.  This will allow you to see all the different parameters and arguments needed.  Once you get it, you're done.

Also, you can go ahead and remove the GPO executionpolicy setting, because you're right, all you have to do is call powershell with an argument of no executionpolicy and you're golden :)

-Dale Harris
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

Suggested Solutions

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…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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