Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Set-ExecutionPolicy in RunOnce doesn't work

Reply
 
Old 05-15-2008   #1 (permalink)
ssg31415926


 
 

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


 
 

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


 
 

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


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
RunOnce tasks in Vista must be completed before desktop is available? General Discussion
RunOnce as Administrator in Vista VB Script
set-executionpolicy PowerShell
Invoking PS script in RunOnce PowerShell
IE 7 Runonce Operation Aborted and other errors. Vista General


Vista Forums 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 Ltd

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