Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Set-ExecutionPolicy in RunOnce doesn't work

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-15-2008   #1 (permalink)
ssg31415926
Guest


 

Set-ExecutionPolicy in RunOnce doesn't work

I'm trying to deploy PowerShell using SMS and I need to set the
ExecutionPolicy to Unrestricted. Occasionally, the installation
requires a restart so I can't just run Set-ExecutionPolicy
Unrestricted in the package.

I was planning to use RunOnce but it doesn't work. Here are some of
the command lines I've tried:

%windir%\system32\windowspowershell\v1.0\powershell.exe Set-
ExecutionPolicy Unrestricted

I've also tried:

%windir%\system32\windowspowershell\v1.0\powershell.exe Set-
ExecutionPolicy Unrestricted > C:\Logs\ps.txt

the file isn't created.

I've also tried -noninteractive with the same result. Does anyone
know why it doesn't work and how to get it to work?

My System SpecsSystem Spec
Old 05-15-2008   #2 (permalink)
Shay Levi
Guest


 

Re: Set-ExecutionPolicy in RunOnce doesn't work



Hi

Try one of the following:

1. PowerShell -Command {Set-ExecutionPolicy Unrestricted}
2. PowerShell -Command "& {Set-ExecutionPolicy Unrestricted}"

I suggest you set it with 'remoteSigned', it is more secure.


You can also set the value through the registry, search for the value 'ExecutionPolicy'
under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell


Or even use a GPO Administrative Templates for Windows PowerShell:
http://www.microsoft.com/downloads/d...DisplayLang=en



---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> I'm trying to deploy PowerShell using SMS and I need to set the
> ExecutionPolicy to Unrestricted. Occasionally, the installation
> requires a restart so I can't just run Set-ExecutionPolicy
> Unrestricted in the package.
>
> I was planning to use RunOnce but it doesn't work. Here are some of
> the command lines I've tried:
>
> %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
> ExecutionPolicy Unrestricted
>
> I've also tried:
>
> %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
> ExecutionPolicy Unrestricted > C:\Logs\ps.txt
>
> the file isn't created.
>
> I've also tried -noninteractive with the same result. Does anyone
> know why it doesn't work and how to get it to work?
>

My System SpecsSystem Spec
Old 05-15-2008   #3 (permalink)
ssg31415926
Guest


 

Re: Set-ExecutionPolicy in RunOnce doesn't work

Thanks very much for the suggestions - I'm playing with the registry
setting at the mo and it's looking good.

On 15 May, 12:19, Shay Levi <n...@xxxxxx> wrote:
Quote:

> Hi
>
> Try one of the following:
>
> 1. PowerShell -Command {Set-ExecutionPolicy Unrestricted}
> 2. PowerShell -Command "& {Set-ExecutionPolicy Unrestricted}"
>
> I suggest you set it with 'remoteSigned', it is more secure.
>
> You can also set the value through the registry, search for the value 'ExecutionPolicy'
> under:
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
>
> Or even use a GPO Administrative Templates for Windows PowerShell:http://www.microsoft.com/downloads/d...D=2917a564-dbb...
>
> ---
> Shay Levi
> $cript Fanatichttp://scriptolog.blogspot.com
>
Quote:

> > I'm trying to deploy PowerShell using SMS and I need to set the
> > ExecutionPolicy to Unrestricted. Occasionally, the installation
> > requires a restart so I can't just run Set-ExecutionPolicy
> > Unrestricted in the package.
>
Quote:

> > I was planning to use RunOnce but it doesn't work. Here are some of
> > the command lines I've tried:
>
Quote:

> > %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
> > ExecutionPolicy Unrestricted
>
Quote:

> > I've also tried:
>
Quote:

> > %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
> > ExecutionPolicy Unrestricted > C:\Logs\ps.txt
>
Quote:

> > the file isn't created.
>
Quote:

> > I've also tried -noninteractive with the same result. Does anyone
> > know why it doesn't work and how to get it to work?
My System SpecsSystem Spec
Old 05-16-2008   #4 (permalink)
Alex K. Angelopoulos
Guest


 

Re: Set-ExecutionPolicy in RunOnce doesn't work

That's the technique that I use. I use a WSH script with WMI's registry
provider; it makes it fairly simple to run through a specific list of
machines and directly inspect and/or set the values.

There are two special situations you should be aware of with the path shown,
moving forward, however.

(1) There are distinct keys for the 32 and 64-bit versions of PowerShell if
you run 64-bit Windows. The path Shay mentioned is for the OS-native-bit
path, so if you want to make sure the 32-bit PowerShell is adjusted on
64-bit Windows, you need to check
HKLM\Software\Wow6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

(2) Moving forward, there will eventually be situations where there are
multiple PowerShell version numbers (not just the subpath 1) and multiple
product identifiers (not just Microsoft.PowerShell). This isn't likely to be
a significant immediate problem, but sometime in the next few years for
blanket inspection/modification on a general OS, you'll need to try
enumerating subkeys under both

HKLM\Software\Microsoft\PowerShell
and
HKLM\Software\Wow6432Node\Microsoft\PowerShell

and for each version number subkey under each of those, you will need to
enumerate product keys under ShellIds. Essentially all valid paths are of
the form:

HKLM\Software\[Wow6432Node\]Microsoft\PowerShell\<version#>\ShellIds\<productname>

Where [Wow6432Node\] is optional.

"ssg31415926" <newsjunkmail@xxxxxx> wrote in message
news:af780be3-26e4-4922-9320-dffdd2c056ea@xxxxxx
Quote:

> Thanks very much for the suggestions - I'm playing with the registry
> setting at the mo and it's looking good.
>
> On 15 May, 12:19, Shay Levi <n...@xxxxxx> wrote:
Quote:

>> Hi
>>
>> Try one of the following:
>>
>> 1. PowerShell -Command {Set-ExecutionPolicy Unrestricted}
>> 2. PowerShell -Command "& {Set-ExecutionPolicy Unrestricted}"
>>
>> I suggest you set it with 'remoteSigned', it is more secure.
>>
>> You can also set the value through the registry, search for the value
>> 'ExecutionPolicy'
>> under:
>> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
>>
>> Or even use a GPO Administrative Templates for Windows
>> PowerShell:http://www.microsoft.com/downloads/d...D=2917a564-dbb...
>>
>> ---
>> Shay Levi
>> $cript Fanatichttp://scriptolog.blogspot.com
>>
Quote:

>> > I'm trying to deploy PowerShell using SMS and I need to set the
>> > ExecutionPolicy to Unrestricted. Occasionally, the installation
>> > requires a restart so I can't just run Set-ExecutionPolicy
>> > Unrestricted in the package.
>>
Quote:

>> > I was planning to use RunOnce but it doesn't work. Here are some of
>> > the command lines I've tried:
>>
Quote:

>> > %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
>> > ExecutionPolicy Unrestricted
>>
Quote:

>> > I've also tried:
>>
Quote:

>> > %windir%\system32\windowspowershell\v1.0\powershell.exe Set-
>> > ExecutionPolicy Unrestricted > C:\Logs\ps.txt
>>
Quote:

>> > the file isn't created.
>>
Quote:

>> > I've also tried -noninteractive with the same result. Does anyone
>> > know why it doesn't work and how to get it to work?
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting batchfile to runonce prior to user logon (winxp sp2) Ben Christian PowerShell 7 04-17-2008 09:43 AM
set-executionpolicy BinaryCoder PowerShell 4 11-30-2007 05:59 PM
Invoking PS script in RunOnce greatbarrier86 PowerShell 3 10-26-2007 10:47 AM
IE 7 Runonce Operation Aborted and other errors. Purtech Vista General 0 08-19-2007 01:35 PM
Set-ExecutionPolicy Unrestricted Stefan Koell PowerShell 28 05-07-2007 09:05 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51