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 IP Address. . . . . . . . . . . . : 18.104.22.168 Subnet Mask . . . . . . . . . . . : 255.255.252.0 Default Gateway . . . . . . . . . : 172.30.180.1 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 Subnet Mask . . . . . . . . . . . : 255.255.252.0
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.