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 - ps1 file type association

Reply
 
Old 02-18-2009   #1 (permalink)
Eero J


 
 

ps1 file type association

I need to set powershell.exe as a default program for .ps1 file types for
every user in one server (server 2008). Can i do it via some registry key? If
i do it via Control panel - Default programs, it only applies to me but not
for other users.

My System SpecsSystem Spec
Old 02-18-2009   #2 (permalink)
Josh Einstein


 
 

Re: ps1 file type association

Bad idea. Not only are you compromising the security of your server, but if
anyone other than you uses the server, double clicking a .ps1 file will act
totally different than the way it is expected. Might I suggest instead
coming up with your own extension for a "runnable" PowerShell script and
only rename the scripts that you absolutely must run by double clicking.
Better yet, just make shortcuts that launch PowerShell.exe with appropriate
command line parameters...

But if you must, you will want to relocate the following registry keys:

HKCR\.ps1 -> HKLM\Software\Classes\.ps1
HKCR\Microsoft.PowerShellScript.1 ->
HKLM\Software\Classes\Microsoft.PowerShellScript.1

Probably easiest to do this in regedit, exporting those keys to text files,
editing them, and re-importing them. I don't really work with the registry
provider in PowerShell much so I don't know how to do that via script off
the top of my head.

Josh

"Eero J" <EeroJ@xxxxxx> wrote in message
news:691CED60-A226-44B6-A133-7666D732A0B9@xxxxxx
Quote:

> I need to set powershell.exe as a default program for .ps1 file types for
> every user in one server (server 2008). Can i do it via some registry key?
> If
> i do it via Control panel - Default programs, it only applies to me but
> not
> for other users.
My System SpecsSystem Spec
Old 02-18-2009   #3 (permalink)
RichS [MVP]


 
 

RE: ps1 file type association

You are compromising your security by doing this. PowerShell deliberately
does not associate powershell.exe with the .ps1 extension to prevent some of
the problems seen with the automatic execution of VBScripts.

call the scripts from batch files rather than doing this
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Eero J" wrote:
Quote:

> I need to set powershell.exe as a default program for .ps1 file types for
> every user in one server (server 2008). Can i do it via some registry key? If
> i do it via Control panel - Default programs, it only applies to me but not
> for other users.
My System SpecsSystem Spec
Old 02-18-2009   #4 (permalink)
John Vottero


 
 

Re: ps1 file type association

"RichS [MVP]" <RichSMVP@xxxxxx> wrote in message
news:22E73585-B8FF-47AC-8BF6-132077629D58@xxxxxx
Quote:

> You are compromising your security by doing this. PowerShell deliberately
> does not associate powershell.exe with the .ps1 extension to prevent some
> of
> the problems seen with the automatic execution of VBScripts.
>
> call the scripts from batch files rather than doing this
How is calling a PowerShell script from a batch file more secure than making
PowerShell.exe the default action for a .ps1 file? If you double-click the
batch file, it will execute the PowerShell script, what's the difference?

My System SpecsSystem Spec
Old 02-18-2009   #5 (permalink)
RichS [MVP]


 
 

Re: ps1 file type association

The difference is that you are executing a single know script rather than
making all scripts executable
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"John Vottero" wrote:
Quote:

> "RichS [MVP]" <RichSMVP@xxxxxx> wrote in message
> news:22E73585-B8FF-47AC-8BF6-132077629D58@xxxxxx
Quote:

> > You are compromising your security by doing this. PowerShell deliberately
> > does not associate powershell.exe with the .ps1 extension to prevent some
> > of
> > the problems seen with the automatic execution of VBScripts.
> >
> > call the scripts from batch files rather than doing this
>
> How is calling a PowerShell script from a batch file more secure than making
> PowerShell.exe the default action for a .ps1 file? If you double-click the
> batch file, it will execute the PowerShell script, what's the difference?
>
My System SpecsSystem Spec
Old 02-18-2009   #6 (permalink)
Josh Einstein


 
 

Re: ps1 file type association

Because .bat files are expected and protected by many security measures such
as attachment blocking, IE zone blocking, virus scanners, etc.

Not to mention, like I said... what if someone other than you logs onto the
machine, sees "Format-HardDrive.ps1" and says "oh that’s weird, let me
double click that to see what it is?".

"John Vottero" <JVottero@xxxxxx> wrote in message
news:BF5259E9-B0B9-4C67-A01F-97EAF98FF17D@xxxxxx
Quote:

> "RichS [MVP]" <RichSMVP@xxxxxx> wrote in message
> news:22E73585-B8FF-47AC-8BF6-132077629D58@xxxxxx
Quote:

>> You are compromising your security by doing this. PowerShell
>> deliberately
>> does not associate powershell.exe with the .ps1 extension to prevent some
>> of
>> the problems seen with the automatic execution of VBScripts.
>>
>> call the scripts from batch files rather than doing this
>
> How is calling a PowerShell script from a batch file more secure than
> making PowerShell.exe the default action for a .ps1 file? If you
> double-click the batch file, it will execute the PowerShell script, what's
> the difference?
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
ISO File Type Association? General Discussion
windows mail and file type association... :-( Browsers & Mail
Change File Type Association Vista General
File type association Vista account administration
Changing the edit association for a file type 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