1. PowerShell Console
Open PowerShell, you can complete dos,cmd and other operations, display the following interface:
650) this.width=650; "src=" http://img1.51cto.com/attachment/201003/082051357.png "border=" 0 "/>
2. Cmdlet commands
It uses a "verb-noun" named form as a cmdlet command
To view all cmdlet commands in the current PowerShell: Get-command
List all commands starting with get-*: Get-command-verb get
Simple examples of other basic common commands:
Get-help <enter>
Get-help * <enter>
Get-service <enter>
Get-help Get-service <enter>
3. Operations on Windows Services
PS d:\users\administrator> Get-service-name Browser
Status Name DisplayName
------ ---- -----------
Stopped Browser Computer Browser
Start-service-name Browser <enter>
Stop-service-name Browser <enter>
4. PowerShell Aliases
The purpose of setting up the alias for PowerShell is to provide the new user with a shell that can interact quickly. The alias here refers to the alternate name of the cmdlet. For example: "Get-childitem" = "dir"
Powshell built-in aliases list:
Command: Get-alias
For example? = Where-object; ls= dir
650) this.width=650; "width=" 650 "src=" http://img1.51cto.com/attachment/201003/152334112.png "border=" 0 "/>
Alias for user-defined PowerShell
command to set Alias
Example: Define an alias for a cmdlet named ' Get-service '
Set-alias gs get-service <enter>
5. After creating good one alias, how to save it, do not lose the alias
Method One: Import and export the aliase of PowerShell
Export-alias-path A.txt
Import-alias-path A.txt (Note When importing, only need to add their favorite alias, the system comes with the need to delete, or will error)
Method Two: Use the PowerShell configuration file
A. Creating a configuration file
$profile = "D:\users\administrator\documents\windowspowershell\microsoft.powershell_profile.ps1″
Includes: Set-alias Marui stop-process
B. Setting up a PowerShell configuration file
$profile = "D:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
C. Reopen PowerShell, test
650) this.width=650; "title=" Capture.png "src=" http://s3.51cto.com/wyfs02/M01/6B/E2/ Wkiol1u5scgsfczoaaewajc04xy810.jpg "alt=" Wkiol1u5scgsfczoaaewajc04xy810.jpg "/>
6. Output
A. Direct output string
PS c:\> "Hello world!"
Hello world!
B. We can store the results in a temporary file and then use the type command to retrieve the results of the file.
PS c:\> (*3/7) > C:\fun.txt
PS c:\> Type C:\fun.txt
1.71428571428571
C. Output of basic operation results
PS c:\> 99 + 100
199
PS c:\> (7-2 * 3)/5
0.2
D. Assigning variables to output
PS c:\> $n = (+)
PS c:\> $n
12
PS c:\> $n/7
1.71428571428571
E. As an object-oriented variable, get the array and output the fourth element (PowerShell array subscript starting from 0)
650) this.width=650; "title=" Capture.png "src=" http://s3.51cto.com/wyfs02/M01/6B/E3/ Wkiol1u5s-bxg2duaajyfrgqop4676.jpg "alt=" Wkiol1u5s-bxg2duaajyfrgqop4676.jpg "/>
This article comes from the "Ricky's blog" blog, please be sure to keep this source http://57388.blog.51cto.com/47388/1637845
3. PowerShell--basic operation, Alias, output