Solved

run a powershell script

Posted on 2012-04-05
3
699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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