powershell.exe command line parameters for V1
-
Tuesday, March 06, 2012 4:53 PM
Hello,
I can only seem to find a PS v2 document regarding the powershell.exe command line parameters...
http://technet.microsoft.com/en-us/library/dd315276.aspxand I don't have a system with v1 readily available. Anyone have a link to this info for v1? or a machine with v1 installed to do a quick powershell.exe /? and copy/paste into a reply here?
Although I'd like to see the full list for v1, I'm most interested in confirming whether or not the "-ExecutionPolicy" parameter is available for v1.
Thanks.
All Replies
-
Tuesday, March 06, 2012 6:16 PM
Hi
Can you please explain what exactly you are trying to achieve?
If you are trying find out whether "-ExecutionPolicy is supported in version 1.0 or not, then then answer is "Yes". It is supported.
Just FYI....You can run specific version of powershell using following command:
powershell.exe -version 1.0
Hope this helps...!!!
Thanks & Regards
Bhavik Solanki
Please click “Mark as Answer” if this post answers your question and click "Vote as Helpful if this Post helps you. -
Tuesday, March 06, 2012 6:21 PM
Yes, that's the main thing I needed t know, whether or not the -ExecutionPolicy command line parameter was available for v1. I was also interested in seeing all the available command line parameters for v1 just to compare it with what's available in v2.
thanks!
-
Tuesday, March 06, 2012 6:29 PM
Try this command:
powershell -version 1.0 /?
Thanks & Regards
Bhavik Solanki
Please click “Mark as Answer” if this post answers your question and click "Vote as Helpful if this Post helps you. -
Tuesday, March 06, 2012 6:29 PM
Here's the full list for you:
powershell[.exe] [-PSConsoleFile <file> | -Version <version>] [-NoLogo] [-NoExit] [-NoProfile] [-NonInteractive] [-OutputFormat {Text | XML}] [-InputFormat {Text | XML}] [-Command { - | <script-block> [-args <arg-array>] | <string> [<CommandParameters>] } ] powershell[.exe] -Help | -? | /? -PSConsoleFile Loads the specified Windows PowerShell console file. To create a console file, use Export-Console in Windows PowerShell. -Version Starts the specified version of Windows PowerShell. -NoLogo Hides the copyright banner at startup. -NoExit Does not exit after running startup commands. -NoProfile Does not use the user profile. -Noninteractive Does not present an interactive prompt to the user. -OutputFormat Determines how output from Windows PowerShell is formatted. Valid values are "Text" (text strings) or "XML" (serialized CLIXML format). -InputFormat Describes the format of data sent to Windows PowerShell. Valid values are "Text" (text strings) or "XML" (serialized CLIXML format). -Command Executes the specified commands (and any parameters) as though they were typed at the Windows PowerShell command prompt, and then exits, unless NoExit is specified. The value of Command can be "-", a string. or a script block. If the value of Command is "-", the command text is read from standard input. Script blocks must be enclosed in braces ({}). You can specify a script block only when running PowerShell.exe in Windows PowerShell. The results of the script are returned to the parent shell as deserialized XML objects, not live objects. If the value of Command is a string, Command must be the last parameter in the command , because any characters typed after the command are interpreted as the command arguments. To write a string that runs a Windows PowerShell command, use the format: "& {<command>}" where the quotation marks indicate a string and the invoke operator (&) causes the command to be executed. -Help, -?, /? Shows this message. If you are typing a powershell.exe command in Windows PowerShell, prepend the command parameters with a hyphen (-), not a forward slash (/). You can use either a hyphen or forward slash in Cmd.exe. EXAMPLES powershell -psconsolefile sqlsnapin.psc1 powershell -version 1.0 -nologo -inputformat text -outputformat XML powershell -command {get-eventlog -logname security} powershell -command "& {get-eventlog -logname security}"Al Dunbar
- Marked As Answer by c0pe Thursday, March 08, 2012 9:42 PM
-
Tuesday, March 06, 2012 7:39 PM
I hate to rain on the parade, but you're all wrong, unfortunately. Using -version 1 with Powershell V2 does absolutely nothing. It does not invoke a version 1 engine.
This is because PS2 is 100% backward-compatible, in that anything written in V1 will work in V2. So if you've based your answer on using this switch, I suggest you reconsider.
Grant Ward, a.k.a. Bigteddy
-
Tuesday, March 06, 2012 7:57 PMyou are correctand if you do use the -version 1.0 and load up powershell (no error) andlook at $host you'll see it says its version 2..that is also the case with V3, you only have V2 as an option (however V1doesn’t cause any failures)
Justin Rich
http://jrich523.wordpress.com
PowerShell V3 Guide (Technet)
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Thursday, March 08, 2012 9:41 PM
Bhavik, nope, you are incorrect. I found a v1 box to check and there is no -ExecutionPolicy or -File parameter. Which means I need to do a really ugly workaround to assure I can use powershell on *all* my servers that have powershell since I have a mix of 1 and 2 and that won't change. Here is the v1 settings, which I see after I left this post previously others have posted as well:
C:\>powershell.exe /?
powershell[.exe] [-PSConsoleFile <file> | -Version <version>]
[-NoLogo] [-NoExit] [-NoProfile] [-NonInteractive]
[-OutputFormat {Text | XML}] [-InputFormat {Text | XML}]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
powershell[.exe] -Help | -? | /?
-PSConsoleFile
Loads the specified Windows PowerShell console file. To create a console
file, use Export-Console in Windows PowerShell.
-Version
Starts the specified version of Windows PowerShell.
-NoLogo
Hides the copyright banner at startup.
-NoExit
Does not exit after running startup commands.
-NoProfile
Does not use the user profile.
-Noninteractive
Does not present an interactive prompt to the user.
-OutputFormat
Determines how output from Windows PowerShell is formatted. Valid values
are "Text" (text strings) or "XML" (serialized CLIXML format).
-InputFormat
Describes the format of data sent to Windows PowerShell. Valid values are
"Text" (text strings) or "XML" (serialized CLIXML format).
-Command
Executes the specified commands (and any parameters) as though they were
typed at the Windows PowerShell command prompt, and then exits, unless
NoExit is specified. The value of Command can be "-", a string. or a
script block.
If the value of Command is "-", the command text is read from standard
input.
Script blocks must be enclosed in braces ({}). You can specify a script
block only when running PowerShell.exe in Windows PowerShell. The results
of the script are returned to the parent shell as deserialized XML objects,
not live objects.
If the value of Command is a string, Command must be the last parameter
in the command , because any characters typed after the command are
interpreted as the command arguments.
To write a string that runs a Windows PowerShell command, use the format:
"& {<command>}"
where the quotation marks indicate a string and the invoke operator (&)
causes the command to be executed.
-Help, -?, /?
Shows this message. If you are typing a powershell.exe command in Windows
PowerShell, prepend the command parameters with a hyphen (-), not a forward
slash (/). You can use either a hyphen or forward slash in Cmd.exe.
EXAMPLES
powershell -psconsolefile sqlsnapin.psc1
powershell -version 1.0 -nologo -inputformat text -outputformat XML
powershell -command {get-eventlog -logname security}
powershell -command "& {get-eventlog -logname security}"
-
Thursday, March 08, 2012 9:43 PMuh... Bigteddy, completely off topic, but thanks for the response anyway. Al gave the right answer to my original post.
-
Thursday, March 08, 2012 9:44 PMthank you Al Dunbar!
-
Friday, March 09, 2012 4:56 AM
uh... Bigteddy, completely off topic, but thanks for the response anyway. Al gave the right answer to my original post.
Not in the least bit off-topic. The others (except Al) all gave their answers based on using PS2 with the -version 1 swich. This doesn't work, and any conclusions make from that experiment are null and void for the purposes of your queston.Grant Ward, a.k.a. Bigteddy
-
Friday, March 09, 2012 4:18 PM
uh... Bigteddy, completely off topic, but thanks for the response anyway. Al gave the right answer to my original post.
Not in the least bit off-topic. The others (except Al) all gave their answers based on using PS2 with the -version 1 swich. This doesn't work, and any conclusions make from that experiment are null and void for the purposes of your queston.
Grant Ward, a.k.a. Bigteddy
I agree. I did not give the *right* answer, so much as the answer that c0pe happened to find most useful for his particular purpose.
The rest of the discussion was useful and not at all off-topic. It is always best to hear a variety of opinions. Even when errors are made and then pointed out as such as Grant has done, the effect is often one of correcting common misunderstandings - always a good thing.
Al Dunbar
-
Friday, March 09, 2012 9:55 PM
Bigteddy, I stand corrected. Apologies. After re-reading I see what happened... I didn't realize the previous posts were based on using the -version 1 switch. So thank you for your very on topic, and useful information. I appreciate it! (and I gave it a 'vote as helpful')
-
Friday, March 09, 2012 9:59 PM
Al, agreed, except that your answer *was* 100% right/correct. It's exactly what I was asking for in my post :)
thanks again.

