Tip: More Powerful Ways to Launch Windows PowerShell
Follow Our Daily Tips
To work with Windows PowerShell, you probably open a console window by clicking Start, pointing to All Programs, pointing to Accessories, pointing to Windows PowerShell, and then choosing Windows PowerShell. Note that this technique starts Windows PowerShell with standard user privileges rather than administrator privileges. So you would not be able to perform many administrative tasks. To start Windows PowerShell with administrator privileges, you need to click Start, point to All Programs, point to Accessories, point to Windows PowerShell, right-click Windows PowerShell, and select Run As Administrator.
But there are other ways to start a Windows PowerShell console. You can use the Search box on the Start menu, use the Run dialog box, or type powershell in an open command-shell window. These techniques allow you to pass arguments to Windows PowerShell, including switches that control how Windows PowerShell works and parameters that execute additional commands. For example, you can start Windows PowerShell in no-logo mode (meaning the logo banner is turned off) by using the startup command powershell -nologo. By default, when you start Windows PowerShell via the command shell, Windows PowerShell runs and then exits. If you want Windows PowerShell to execute a command and not terminate, type powershell /noexit followed by the command text.
Here is a listing of the available startup parameters:
-Command Specifies the command text to execute as though it were typed at the PowerShell command prompt.
-EncodedCommand Specifies the base64-encoded command text to execute.
-ExecutionPolicy Sets the default execution policy for the console session.
-File Sets the name of a script fi le to execute.
-InputFormat Sets the format for data sent to PowerShell as either text string or serialized XML. The default format is XML. Valid values are text and XML.
-NoExit Does not exit after running startup commands. This parameter is useful when you run PowerShell commands or scripts via the command prompt (cmd.exe).
-NoLogo Starts the PowerShell console without displaying the copyright banner.
-Noninteractive Starts the PowerShell console in non-interactive mode. In this mode, PowerShell does not present an interactive prompt to the user.
-NoProfile Tells the PowerShell console not to load the current user’s profile.
-OutputFormat Sets the format for output as either text string or serialized XML. The default format is text. Valid values are text and XML.
-PSConsoleFile Loads the specified Windows PowerShell console file. Console files end with the .psc1 extension and can be used to ensure that specific snap-in extensions are loaded and available. You can create a console file using Export-Console in Windows PowerShell.
-Sta Starts PowerShell in single-threaded mode.
-Version Sets the version of Windows PowerShell to use for compatibility, such as 1.0.
-WindowStyle Sets the window style as Normal, Minimized, Maximized, or Hidden. The default is Normal.
From the Microsoft Press book Windows PowerShell 2.0 Administrator’s Pocket Consultant by William R. Stanek.
Looking for More Tips?
For more tips on Windows 7 and other Microsoft technologies, visit the TechNet Magazine Tips library.