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 extension not recognized

Reply
 
Old 04-06-2009   #1 (permalink)
King Coffee


 
 

ps1 extension not recognized

Hi,

I'm running PowerShell via VISTA. I created a ps1 script file and tried to
run it from within the powershell command interpret. The ps1 script file
extension is not recognized as a default command script. How do I set the
file extensions that will be recognized by PowerShell?

King


My System SpecsSystem Spec
Old 04-06-2009   #2 (permalink)
Charlie Russel - MVP


 
 

Re: ps1 extension not recognized

The .PS1 extension isn't recognized as a security measure. Double-clicking
on a .PS1 file will cause it to open in Notepad, as well. This was a
considered choice by the PowerShell team, and one I understand from a
security perspective.

However, if after you've carefully considered the security implications, and
still want to have the .PS1 extension be recognized as an executable, you
_could_ add .PS1 to the end of the PATHEXT variable for Windows.

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel

"King Coffee" <kcoffee@xxxxxx> wrote in message
news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
Quote:

> Hi,
>
> I'm running PowerShell via VISTA. I created a ps1 script file and tried to
> run it from within the powershell command interpret. The ps1 script file
> extension is not recognized as a default command script. How do I set the
> file extensions that will be recognized by PowerShell?
>
> King
My System SpecsSystem Spec
Old 04-06-2009   #3 (permalink)
Alex K. Angelopoulos


 
 

Re: ps1 extension not recognized

Could you check how you're doing this again, and post details? The reason I
say this is that you've got two different partial answers based on people
possibly misinterpreting what you actually did.

(A) If you WERE within PowerShell, running a PowerShell script, you might
have one of two problems (or both together).
(1) PowerShell script execution might not be enabled; to do that, you need
to run powershell with elevated privileges (right-click the PS shortcut and
Run As Administrator) and explicitly enable script execution. The following
command should allow local scripts to execute, even if unsigned:
Set-ExecutionPolicy RemoteSigned
If this is the problem and PowerShell can find the script, you would be
likely to get a message explicitly telling you script execution is disabled.
(2) As Robert mentions, PowerShell doesn't search the current PowerShell
location for scripts, by default. In that case, you would get a message
similar to
"The term 'foo.ps1' is not recognized as a cmdlet, function, operable
program, or script file."
Any of the workarounds Robert suggests would work.

(B) If you were NOT running within PowerShell, you're going to have several
issues with arbitrarily running a PowerShell script; generally you would
need to specify an entire command line using PowerShell's syntax. The error
you get would be something like this:
"'foo.ps1' is not recognized as an internal or external command,
operable program or batch file."
Note that is almost identical to the wording of the error from within
PowerShell, with the word "script" changed to "batch". Charlie's answer
isn't quite complete, I believe he's forgotten about some of the file
association work that's done by magic on Unix, but not on Windows. : )

"King Coffee" <kcoffee@xxxxxx> wrote in message
news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
Quote:

> Hi,
>
> I'm running PowerShell via VISTA. I created a ps1 script file and tried to
> run it from within the powershell command interpret. The ps1 script file
> extension is not recognized as a default command script. How do I set the
> file extensions that will be recognized by PowerShell?
>
> King
My System SpecsSystem Spec
Old 04-06-2009   #4 (permalink)
Alex K. Angelopoulos


 
 

Re: ps1 extension not recognized

FYI, Charlie - that's necessary, but not sufficient. It still would need
filetype association set up (which gets really whacky, at least with PS1,
due to the fact that the filepath is parsed using PowerShell's syntax
rules), otherwise you simply get a searchable way to open the script in
notepad. : )

"Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
news:#5vDm$mtJHA.1492@xxxxxx
Quote:

> The .PS1 extension isn't recognized as a security measure. Double-clicking
> on a .PS1 file will cause it to open in Notepad, as well. This was a
> considered choice by the PowerShell team, and one I understand from a
> security perspective.
>
> However, if after you've carefully considered the security implications,
> and still want to have the .PS1 extension be recognized as an executable,
> you _could_ add .PS1 to the end of the PATHEXT variable for Windows.
>
> --
> Charlie.
> http://msmvps.com/blogs/xperts64
> http://mvp.support.microsoft.com/profile/charlie.russel
>
> "King Coffee" <kcoffee@xxxxxx> wrote in message
> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
Quote:

>> Hi,
>>
>> I'm running PowerShell via VISTA. I created a ps1 script file and tried
>> to run it from within the powershell command interpret. The ps1 script
>> file extension is not recognized as a default command script. How do I
>> set the file extensions that will be recognized by PowerShell?
>>
>> King
>
My System SpecsSystem Spec
Old 04-06-2009   #5 (permalink)
Charlie Russel - MVP


 
 

Re: ps1 extension not recognized

From the PowerShell command line, that is sufficient. (from the GUI, you are
correct.) But from the PoSH command line, adding to the PATHEXT variable is
sufficient to save me from having to type "myscript.ps1" to execute it - I
only need to type "myscript". (Well, and depending on other factors, I may
or may not have to preceed with an ampersand, but that's a different
discussion.)

I know this works, Alex, since I got lazy on my own network and made the
change. But I did NOT change how the GUI association works. That was too
scary.

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:%23Co$SmotJHA.5172@xxxxxx
Quote:

> FYI, Charlie - that's necessary, but not sufficient. It still would need
> filetype association set up (which gets really whacky, at least with PS1,
> due to the fact that the filepath is parsed using PowerShell's syntax
> rules), otherwise you simply get a searchable way to open the script in
> notepad. : )
>
> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
> news:#5vDm$mtJHA.1492@xxxxxx
Quote:

>> The .PS1 extension isn't recognized as a security measure.
>> Double-clicking on a .PS1 file will cause it to open in Notepad, as well.
>> This was a considered choice by the PowerShell team, and one I understand
>> from a security perspective.
>>
>> However, if after you've carefully considered the security implications,
>> and still want to have the .PS1 extension be recognized as an executable,
>> you _could_ add .PS1 to the end of the PATHEXT variable for Windows.
>>
>> --
>> Charlie.
>> http://msmvps.com/blogs/xperts64
>> http://mvp.support.microsoft.com/profile/charlie.russel
>>
>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
Quote:

>>> Hi,
>>>
>>> I'm running PowerShell via VISTA. I created a ps1 script file and tried
>>> to run it from within the powershell command interpret. The ps1 script
>>> file extension is not recognized as a default command script. How do I
>>> set the file extensions that will be recognized by PowerShell?
>>>
>>> King
>>
My System SpecsSystem Spec
Old 04-06-2009   #6 (permalink)
Alex K. Angelopoulos


 
 

Re: ps1 extension not recognized

Do you recall when you first had to add the extension to pathext - and would
you care to retest?

I'm asking because at least during release, I've never needed to add the
extension to make PowerShell recognize ps1 scripts as searchable items.
During command lookup, in each directory in the search path, PowerShell
automatically checks for .ps1 scripts matching a given base name before
running through the pathext extensions.

That said, I don't have the foggiest idea how the injection occurs, but
nonetheless, it works for me without hiccups on both x86 and x64 systems and
is doing so right now without having it explicitly set in pathext.


"Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
news:eGw9NUrtJHA.4648@xxxxxx
Quote:

> From the PowerShell command line, that is sufficient. (from the GUI, you
> are correct.) But from the PoSH command line, adding to the PATHEXT
> variable is sufficient to save me from having to type "myscript.ps1" to
> execute it - I only need to type "myscript". (Well, and depending on other
> factors, I may or may not have to preceed with an ampersand, but that's a
> different discussion.)
>
> I know this works, Alex, since I got lazy on my own network and made the
> change. But I did NOT change how the GUI association works. That was too
> scary.
>
> --
> Charlie.
> http://msmvps.com/blogs/xperts64
> http://mvp.support.microsoft.com/profile/charlie.russel
>
> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
> news:%23Co$SmotJHA.5172@xxxxxx
Quote:

>> FYI, Charlie - that's necessary, but not sufficient. It still would need
>> filetype association set up (which gets really whacky, at least with PS1,
>> due to the fact that the filepath is parsed using PowerShell's syntax
>> rules), otherwise you simply get a searchable way to open the script in
>> notepad. : )
>>
>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
>> news:#5vDm$mtJHA.1492@xxxxxx
Quote:

>>> The .PS1 extension isn't recognized as a security measure.
>>> Double-clicking on a .PS1 file will cause it to open in Notepad, as
>>> well. This was a considered choice by the PowerShell team, and one I
>>> understand from a security perspective.
>>>
>>> However, if after you've carefully considered the security implications,
>>> and still want to have the .PS1 extension be recognized as an
>>> executable, you _could_ add .PS1 to the end of the PATHEXT variable for
>>> Windows.
>>>
>>> --
>>> Charlie.
>>> http://msmvps.com/blogs/xperts64
>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>
>>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
>>>> Hi,
>>>>
>>>> I'm running PowerShell via VISTA. I created a ps1 script file and tried
>>>> to run it from within the powershell command interpret. The ps1 script
>>>> file extension is not recognized as a default command script. How do I
>>>> set the file extensions that will be recognized by PowerShell?
>>>>
>>>> King
>>>
>
My System SpecsSystem Spec
Old 04-07-2009   #7 (permalink)
Charlie Russel - MVP


 
 

Re: ps1 extension not recognized

Hmmm. Gosh, I have no idea when. Certainly way back in the Monad days, Alex.
I first wrote my RDP script back then, I'm sure. It's now gotten a good deal
smarter, and does both RDP and VMConnect sessions, depending on the name
it's called by. And I keep thinking what I really want to do is change it
again to accept a command line parameter to chose between mstsc and
vmconnect to the same virtual machine, but that might get a bit trickier
than I want to bother with, so haven't done it yet.

Tell you what, I'll go turn off PATHEXT and see if it still works without
the .ps1 added to the command name. Back shortly...

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:eOGoicxtJHA.3988@xxxxxx
Quote:

> Do you recall when you first had to add the extension to pathext - and
> would you care to retest?
>
> I'm asking because at least during release, I've never needed to add the
> extension to make PowerShell recognize ps1 scripts as searchable items.
> During command lookup, in each directory in the search path, PowerShell
> automatically checks for .ps1 scripts matching a given base name before
> running through the pathext extensions.
>
> That said, I don't have the foggiest idea how the injection occurs, but
> nonetheless, it works for me without hiccups on both x86 and x64 systems
> and is doing so right now without having it explicitly set in pathext.
>
>
> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
> news:eGw9NUrtJHA.4648@xxxxxx
Quote:

>> From the PowerShell command line, that is sufficient. (from the GUI, you
>> are correct.) But from the PoSH command line, adding to the PATHEXT
>> variable is sufficient to save me from having to type "myscript.ps1" to
>> execute it - I only need to type "myscript". (Well, and depending on
>> other factors, I may or may not have to preceed with an ampersand, but
>> that's a different discussion.)
>>
>> I know this works, Alex, since I got lazy on my own network and made the
>> change. But I did NOT change how the GUI association works. That was too
>> scary.
>>
>> --
>> Charlie.
>> http://msmvps.com/blogs/xperts64
>> http://mvp.support.microsoft.com/profile/charlie.russel
>>
>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>> news:%23Co$SmotJHA.5172@xxxxxx
Quote:

>>> FYI, Charlie - that's necessary, but not sufficient. It still would need
>>> filetype association set up (which gets really whacky, at least with
>>> PS1, due to the fact that the filepath is parsed using PowerShell's
>>> syntax rules), otherwise you simply get a searchable way to open the
>>> script in notepad. : )
>>>
>>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in
>>> message news:#5vDm$mtJHA.1492@xxxxxx
>>>> The .PS1 extension isn't recognized as a security measure.
>>>> Double-clicking on a .PS1 file will cause it to open in Notepad, as
>>>> well. This was a considered choice by the PowerShell team, and one I
>>>> understand from a security perspective.
>>>>
>>>> However, if after you've carefully considered the security
>>>> implications, and still want to have the .PS1 extension be recognized
>>>> as an executable, you _could_ add .PS1 to the end of the PATHEXT
>>>> variable for Windows.
>>>>
>>>> --
>>>> Charlie.
>>>> http://msmvps.com/blogs/xperts64
>>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>>
>>>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>>>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
>>>>> Hi,
>>>>>
>>>>> I'm running PowerShell via VISTA. I created a ps1 script file and
>>>>> tried to run it from within the powershell command interpret. The ps1
>>>>> script file extension is not recognized as a default command script.
>>>>> How do I set the file extensions that will be recognized by
>>>>> PowerShell?
>>>>>
>>>>> King
>>>>
>>
My System SpecsSystem Spec
Old 04-07-2009   #8 (permalink)
Charlie Russel - MVP


 
 

Re: ps1 extension not recognized

Hunh! You're absolutely right, Alex. It had become so automatic that I
hadn't tested it in ages, and it is certainly no longer required. Well, I
learn something every day, and you get the prize for being today's teacher.
<G>

The annoying thing is that I'm sure I've included that in at least one book,
which means I'll have to watch for it if we do a new edition. Sigh.

One interesting byproduct of adding it to PATHEXT, by the way, is that if
you do, and you try to run the script from the CMD command line, what
happens is that it opens notepad with the file in it. Which is, of course,
what we would expect and want.

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:eOGoicxtJHA.3988@xxxxxx
Quote:

> Do you recall when you first had to add the extension to pathext - and
> would you care to retest?
>
> I'm asking because at least during release, I've never needed to add the
> extension to make PowerShell recognize ps1 scripts as searchable items.
> During command lookup, in each directory in the search path, PowerShell
> automatically checks for .ps1 scripts matching a given base name before
> running through the pathext extensions.
>
> That said, I don't have the foggiest idea how the injection occurs, but
> nonetheless, it works for me without hiccups on both x86 and x64 systems
> and is doing so right now without having it explicitly set in pathext.
>
>
> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
> news:eGw9NUrtJHA.4648@xxxxxx
Quote:

>> From the PowerShell command line, that is sufficient. (from the GUI, you
>> are correct.) But from the PoSH command line, adding to the PATHEXT
>> variable is sufficient to save me from having to type "myscript.ps1" to
>> execute it - I only need to type "myscript". (Well, and depending on
>> other factors, I may or may not have to preceed with an ampersand, but
>> that's a different discussion.)
>>
>> I know this works, Alex, since I got lazy on my own network and made the
>> change. But I did NOT change how the GUI association works. That was too
>> scary.
>>
>> --
>> Charlie.
>> http://msmvps.com/blogs/xperts64
>> http://mvp.support.microsoft.com/profile/charlie.russel
>>
>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>> news:%23Co$SmotJHA.5172@xxxxxx
Quote:

>>> FYI, Charlie - that's necessary, but not sufficient. It still would need
>>> filetype association set up (which gets really whacky, at least with
>>> PS1, due to the fact that the filepath is parsed using PowerShell's
>>> syntax rules), otherwise you simply get a searchable way to open the
>>> script in notepad. : )
>>>
>>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in
>>> message news:#5vDm$mtJHA.1492@xxxxxx
>>>> The .PS1 extension isn't recognized as a security measure.
>>>> Double-clicking on a .PS1 file will cause it to open in Notepad, as
>>>> well. This was a considered choice by the PowerShell team, and one I
>>>> understand from a security perspective.
>>>>
>>>> However, if after you've carefully considered the security
>>>> implications, and still want to have the .PS1 extension be recognized
>>>> as an executable, you _could_ add .PS1 to the end of the PATHEXT
>>>> variable for Windows.
>>>>
>>>> --
>>>> Charlie.
>>>> http://msmvps.com/blogs/xperts64
>>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>>
>>>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>>>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
>>>>> Hi,
>>>>>
>>>>> I'm running PowerShell via VISTA. I created a ps1 script file and
>>>>> tried to run it from within the powershell command interpret. The ps1
>>>>> script file extension is not recognized as a default command script.
>>>>> How do I set the file extensions that will be recognized by
>>>>> PowerShell?
>>>>>
>>>>> King
>>>>
>>
My System SpecsSystem Spec
Old 04-07-2009   #9 (permalink)
Alex K. Angelopoulos


 
 

Re: ps1 extension not recognized

I think you can call that a feature, then. It doesn't actually _cause_ a
problem for anything; you just added graphical functionality for inspecting
PowerShell scripts! : D

"Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
news:ua0Vnx4tJHA.1300@xxxxxx
Quote:

> Hunh! You're absolutely right, Alex. It had become so automatic that I
> hadn't tested it in ages, and it is certainly no longer required. Well, I
> learn something every day, and you get the prize for being today's
> teacher. <G>
>
> The annoying thing is that I'm sure I've included that in at least one
> book, which means I'll have to watch for it if we do a new edition. Sigh.
>
> One interesting byproduct of adding it to PATHEXT, by the way, is that if
> you do, and you try to run the script from the CMD command line, what
> happens is that it opens notepad with the file in it. Which is, of course,
> what we would expect and want.
>
> --
> Charlie.
> http://msmvps.com/blogs/xperts64
> http://mvp.support.microsoft.com/profile/charlie.russel
>
> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
> news:eOGoicxtJHA.3988@xxxxxx
Quote:

>> Do you recall when you first had to add the extension to pathext - and
>> would you care to retest?
>>
>> I'm asking because at least during release, I've never needed to add the
>> extension to make PowerShell recognize ps1 scripts as searchable items.
>> During command lookup, in each directory in the search path, PowerShell
>> automatically checks for .ps1 scripts matching a given base name before
>> running through the pathext extensions.
>>
>> That said, I don't have the foggiest idea how the injection occurs, but
>> nonetheless, it works for me without hiccups on both x86 and x64 systems
>> and is doing so right now without having it explicitly set in pathext.
>>
>>
>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
>> news:eGw9NUrtJHA.4648@xxxxxx
Quote:

>>> From the PowerShell command line, that is sufficient. (from the GUI, you
>>> are correct.) But from the PoSH command line, adding to the PATHEXT
>>> variable is sufficient to save me from having to type "myscript.ps1" to
>>> execute it - I only need to type "myscript". (Well, and depending on
>>> other factors, I may or may not have to preceed with an ampersand, but
>>> that's a different discussion.)
>>>
>>> I know this works, Alex, since I got lazy on my own network and made the
>>> change. But I did NOT change how the GUI association works. That was too
>>> scary.
>>>
>>> --
>>> Charlie.
>>> http://msmvps.com/blogs/xperts64
>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>
>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>> news:%23Co$SmotJHA.5172@xxxxxx
>>>> FYI, Charlie - that's necessary, but not sufficient. It still would
>>>> need filetype association set up (which gets really whacky, at least
>>>> with PS1, due to the fact that the filepath is parsed using
>>>> PowerShell's syntax rules), otherwise you simply get a searchable way
>>>> to open the script in notepad. : )
>>>>
>>>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in
>>>> message news:#5vDm$mtJHA.1492@xxxxxx
>>>>> The .PS1 extension isn't recognized as a security measure.
>>>>> Double-clicking on a .PS1 file will cause it to open in Notepad, as
>>>>> well. This was a considered choice by the PowerShell team, and one I
>>>>> understand from a security perspective.
>>>>>
>>>>> However, if after you've carefully considered the security
>>>>> implications, and still want to have the .PS1 extension be recognized
>>>>> as an executable, you _could_ add .PS1 to the end of the PATHEXT
>>>>> variable for Windows.
>>>>>
>>>>> --
>>>>> Charlie.
>>>>> http://msmvps.com/blogs/xperts64
>>>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>>>
>>>>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>>>>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
>>>>>> Hi,
>>>>>>
>>>>>> I'm running PowerShell via VISTA. I created a ps1 script file and
>>>>>> tried to run it from within the powershell command interpret. The ps1
>>>>>> script file extension is not recognized as a default command script.
>>>>>> How do I set the file extensions that will be recognized by
>>>>>> PowerShell?
>>>>>>
>>>>>> King
>>>>>
>>>
>
My System SpecsSystem Spec
Old 04-07-2009   #10 (permalink)
Charlie Russel - MVP


 
 

Re: ps1 extension not recognized

Grin. Thanks again.

--
Charlie.
http://msmvps.com/blogs/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:%23bKb8h5tJHA.4068@xxxxxx
Quote:

>I think you can call that a feature, then. It doesn't actually _cause_ a
>problem for anything; you just added graphical functionality for inspecting
>PowerShell scripts! : D
>
> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message
> news:ua0Vnx4tJHA.1300@xxxxxx
Quote:

>> Hunh! You're absolutely right, Alex. It had become so automatic that I
>> hadn't tested it in ages, and it is certainly no longer required. Well, I
>> learn something every day, and you get the prize for being today's
>> teacher. <G>
>>
>> The annoying thing is that I'm sure I've included that in at least one
>> book, which means I'll have to watch for it if we do a new edition. Sigh.
>>
>> One interesting byproduct of adding it to PATHEXT, by the way, is that if
>> you do, and you try to run the script from the CMD command line, what
>> happens is that it opens notepad with the file in it. Which is, of
>> course, what we would expect and want.
>>
>> --
>> Charlie.
>> http://msmvps.com/blogs/xperts64
>> http://mvp.support.microsoft.com/profile/charlie.russel
>>
>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>> news:eOGoicxtJHA.3988@xxxxxx
Quote:

>>> Do you recall when you first had to add the extension to pathext - and
>>> would you care to retest?
>>>
>>> I'm asking because at least during release, I've never needed to add the
>>> extension to make PowerShell recognize ps1 scripts as searchable items.
>>> During command lookup, in each directory in the search path, PowerShell
>>> automatically checks for .ps1 scripts matching a given base name before
>>> running through the pathext extensions.
>>>
>>> That said, I don't have the foggiest idea how the injection occurs, but
>>> nonetheless, it works for me without hiccups on both x86 and x64 systems
>>> and is doing so right now without having it explicitly set in pathext.
>>>
>>>
>>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in
>>> message news:eGw9NUrtJHA.4648@xxxxxx
>>>> From the PowerShell command line, that is sufficient. (from the GUI,
>>>> you are correct.) But from the PoSH command line, adding to the PATHEXT
>>>> variable is sufficient to save me from having to type "myscript.ps1" to
>>>> execute it - I only need to type "myscript". (Well, and depending on
>>>> other factors, I may or may not have to preceed with an ampersand, but
>>>> that's a different discussion.)
>>>>
>>>> I know this works, Alex, since I got lazy on my own network and made
>>>> the change. But I did NOT change how the GUI association works. That
>>>> was too scary.
>>>>
>>>> --
>>>> Charlie.
>>>> http://msmvps.com/blogs/xperts64
>>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>>
>>>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
>>>> news:%23Co$SmotJHA.5172@xxxxxx
>>>>> FYI, Charlie - that's necessary, but not sufficient. It still would
>>>>> need filetype association set up (which gets really whacky, at least
>>>>> with PS1, due to the fact that the filepath is parsed using
>>>>> PowerShell's syntax rules), otherwise you simply get a searchable way
>>>>> to open the script in notepad. : )
>>>>>
>>>>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in
>>>>> message news:#5vDm$mtJHA.1492@xxxxxx
>>>>>> The .PS1 extension isn't recognized as a security measure.
>>>>>> Double-clicking on a .PS1 file will cause it to open in Notepad, as
>>>>>> well. This was a considered choice by the PowerShell team, and one I
>>>>>> understand from a security perspective.
>>>>>>
>>>>>> However, if after you've carefully considered the security
>>>>>> implications, and still want to have the .PS1 extension be recognized
>>>>>> as an executable, you _could_ add .PS1 to the end of the PATHEXT
>>>>>> variable for Windows.
>>>>>>
>>>>>> --
>>>>>> Charlie.
>>>>>> http://msmvps.com/blogs/xperts64
>>>>>> http://mvp.support.microsoft.com/profile/charlie.russel
>>>>>>
>>>>>> "King Coffee" <kcoffee@xxxxxx> wrote in message
>>>>>> news:844823B6-7088-4210-A7E4-AAEEDE69B48E@xxxxxx
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm running PowerShell via VISTA. I created a ps1 script file and
>>>>>>> tried to run it from within the powershell command interpret. The
>>>>>>> ps1 script file extension is not recognized as a default command
>>>>>>> script. How do I set the file extensions that will be recognized by
>>>>>>> PowerShell?
>>>>>>>
>>>>>>> King
>>>>>>
>>>>
>>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
pps extension Vista General
File Extension VB Script
wmv Extension Vista mail
CHM file extension not recognized or supported Vista file management
New extension Vista mail


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