Export (0) Print
Expand All

Windows Commands and Utilities

Published: May 20, 2009

Updated: August 9, 2012

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

You can run Windows command-line programs in Windows PowerShell, and you can start Windows programs that have a graphical user interface, such as Notepad and Calculator, at the Windows Powershell prompt. You can also capture the text that Windows programs generate and use that text in Windows PowerShell.

For example, the following commands use Windows, the IPConfig, Net, and Shutdown commands.

C:\PS> net localgroup administrators /add domain01\user01
The command completed successfully.

C:\PS> ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
       Connection-specific DNS Suffix  . : domain.corp.fabricam.com
       Default Gateway . . . . . . . . . :

C:\PS> shutdown -r

You can even use Windows PowerShell cmdlets, like Select-String, to manipulate the text that Windows programs return.

For example, the following command uses a pipeline operator to send the results of an IPConfig command to the Windows PowerShell Select-String cmdlet, which searches for text in strings. In this case, you use Select-String to find the pattern "255" in the IpConfig output.

C:\PS> ipconfig | select-string -pattern 255

When a Windows command or tool has parameters, such as the "-r" (restart) parameter of Shutdown, Windows PowerShell passes the parameters to the tool without interpreting them.

However, if the tool uses a Windows PowerShell reserved word, or uses a command format that is unfamiliar to Windows PowerShell, such as Nant's "-D:debug=false" parameter (Windows PowerShell interprets this as two parameters, "-D" and "debug=false"), enclose the parameters in quotations marks to indicate to Windows PowerShell that it should send the parameters to the tool without interpretation.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft