Solved

run a powershell script

Posted on 2012-04-05
3
692 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article will help you understand what HashTables are and how to use them in PowerShell.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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.

728 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

11 Experts available now in Live!

Get 1:1 Help Now