Basic powershell knowledge point
1. The file name of the powershell script file is extended with. PS1 (note that it is the number 1)
2. powershell execution Policy
The default value is restricted. You can use the following command to obtain the current execution policy:
Get-executionpolicy
Optional execution policies are as follows:
Restricted-the script cannot be run.
Remotesigned-locally created scripts can run, but scripts downloaded from the Internet cannot run (unless they have a digital signature signed by a trusted publisher)
Allsigned-the script can only run if it is signed by a trusted publisher.
Unrestricted-script execution is unrestricted, regardless of the source or signature
You can use the following cmdlet command to reset the execution policy:
Set-executionpolicy <Policy Name>
3. Run the script
Enter the full path of the script, such as D: \ scripts \ script. PSI.
If the script file is located in the system directory, you can type. \ script. PSI to run it.
Note. \ cannot save
4. Pipelines
Get-process | sort-Object ID
Obtain the process list and sort by process ID
5. Variables
$ A = Get-Process
$ B = (get-process | sort-Object ID)
6. @ symbol
You can use the @ symbol to convert the list content to an array, for example:
$ Procs =@{ name = "Explorer", "taskmgr "}
Get-process @ procs
Add @ in the second line to ensure that procs is processed as an array
7. Split
"This is a test"-split ""
8. Join
"Hello", "world"-join ","
9. breakpoint
Insert a breakpoint Based on the row number:
New-psbreakpint-script D: \ scripts \ script. PS1-line 10
Insert a breakpoint in line 2 of the script
You can also bind a breakpoint to a variable:
New-psbreakpoint-script D: \ scripts \ script. PS1-variables
Other Commands include:
Get-psbreakpoint
Enable-psbreakpoint
Disable-psbreakpoint
Remove-psbreakpoint
10. Single-step debugging
Step-
Step-out