is it possible to set GPOduring migration to setexecution policy to unrestricted and then turn it off?

is it possible to set GPO during migration to setexecution policy to unrestricted and then turn it off? If it recommended, then how to set it up.

THank you very much.
creative555Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subash SundharanIT Infrastructure Architect Commented:
You could temporarily bypass the execution policy..

Powershell -executionpolicy bypass -file “C:\test\Script.ps1″

Open in new window

creative555Author Commented:
where do you put this? In the script that I want to run or GPO?
creative555Author Commented:
t C:\migprep\ServicesInventoryScript.ps1:1 char:42
 Powershell -executionpolicy bypass -file <<<< "C:\migprep\ServicesInventoryScript.ps1?
s missing the terminator: ".
t C:\migprep\ServicesInventoryScript.ps1:4 char:1
  <<<<
   + CategoryInfo : ParserError: (C:\migprep\Serv...csv -notype
String) [], ParentContainsErrorRecordException
   + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

Subash SundharanIT Infrastructure Architect Commented:
looks like a copy paste error, try to type the command instead of copying. Also did you keep the script name inside the double quotes?

 
Powershell -executionpolicy bypass -file "C:\test\Script.ps1"

Open in new window

creative555Author Commented:
Like this below? I would put your line infront of the script and save?


powershell.exe -executionpolicy bypass -file "c:\miprep\ServicesInventoryScript.ps1 
get-wmiobject win32_service  | select name, displayname, startmode,state,systemname, startname | export-csv $env:computername.csv -notype
creative555Author Commented:
hm. I ran the command by itself and it shows  this:

>>
>>
I tried to type then my script name then>>.\scriptname
And I get an error that scripts is disabled on this system
Subash SundharanIT Infrastructure Architect Commented:
Nope.. the command should be run from command prompt, no need to add it to the script..


 powershell.exe -executionpolicy bypass -file "c:\miprep\ServicesInventoryScript.ps1"

Open in new window

creative555Author Commented:
oh. OK. THanks so much!!. But I have about 10 scripts to run. Can I do a batch file with the list of 10 scripts and then just click it one?

Smth like this??
powershell.exe -executionpolicy bypass -file "c:\miprep\ServicesInventoryScript.ps1"
powershell.exe -executionpolicy bypass -file "c:\miprep\ServicesInventoryScript2.ps1"
powershell.exe -executionpolicy bypass -file "c:\miprep\ServicesInventoryScript3.ps1"
Subash SundharanIT Infrastructure Architect Commented:
You are probably missing the closing quotes..

Missing closeing quotes..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Subash SundharanIT Infrastructure Architect Commented:
Yes you can do that.. or call all the scripts from a single script will also work..
creative555Author Commented:
I executed command successfully from the CMD but then I tried to run the script and it still tells me that execution policy is disabled on this system
creative555Author Commented:
I successfully executed command like you showed but when I run the script it still tells me that execution policy is disabled. (:

PS C:\migprep> powershell -executionpolicy bypass -file "c:\migprep\ServicesInventoryScript.ps1"
PS C:\migprep> .\ServicesInventoryScript.ps1
File C:\migprep\ServicesInventoryScript.ps1 cannot be loaded because the execution of scripts is disabled on this sys
m. Please see "get-help about_signing" for more details.
At line:1 char:30
+ .\ServicesInventoryScript.ps1 <<<<
    + CategoryInfo : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException
Subash SundharanIT Infrastructure Architect Commented:
You have to run the scripts using this command.. Hope the screenshot explains it well.. Run the script using powershell.exe
creative555Author Commented:
Thank you so much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.