上QQ阅读APP看书,第一时间看更新
How to do it...
Please perform the following steps:
- Start PowerShell Core.
- Type New-Item -Path variable: -Name myVariable -Value "Isn't it great?.
- Type $myVariable. $myVariable is a variable—a temporary storage space for your data. Just executing the variable will place it on the output.
- Type Get-ChildItem $home *.*. This cmdlet uses no parameter names, and only parameter values. $home is a built-in variable and *.* filters for all files with a dot in the name.
- Type Get-ChildItem *.txt $home. Observe the error this time. You can't mix positional parameters.
- Type Get-ChildItem -Filter *.txt -Path $home. By using the parameter names, the cmdlet works again.
- Type $processName = 'powershell'. Assigning anything to a variable like this will store the result in the variable.
- Type Get-Process $processName.
- Type Get-Process $pid. As opposed to the process name, using an ID will fail the cmdlet.
- Type Get-Process -Id $pid. By using the correct parameter, the cmdlet works again.
- Type Get-Command -Syntax -Name Get-Process. Observe the syntax of the cmdlet; there's more than one way to execute a cmdlet. These are called parameter sets.