Chapter 1: Powershell – introduces
Get-Alias #Get alias of commands
Get-Alias -Definition Get-Process
Update-help -Force #update help library
Chapter 2: Powershell – help
Get help + command #Get help detail of the command (Man, –help is the same)
Get-help *service* #List help of the service-related command
Get-help g*service*
Get-verb # Get all the verb command
Get-verb # Get the verb command and count it
Get-help get-service -Detailed # Get detailed help of “Get-service”
Get-help get-service -online #Check help online
Get-Help Get-Service -Examples # Get help show examples
Get-Help Get-Service -ShowWindow # Show running window
Get-Service -Name bits,bfe Get-Service -Name b,c #Check mutiple service
Get-Service -DisplayName Print* # Get the fullname of part of the full name of service
Get-EventLog -LogName System -Newest 3 -EntryType error -ComputerName XSHQSDC01,XSHQSVeeam01,Win11PC # Check the latest error system log from 3 computers
CLS ; HELP about_Eventlogs : Clear screen and excute abother command
Get-Help -Category Provider # Get help with categary
Chapter 3: Powershell – Pipe
Get-Service -Name bits | Stop-Service
Get-Service | Export-Csv -Path C:\temp\service.csv # Export service to csv file
notepad C:\temp\service.csv # Notepad open csv file
Import-Csv C:\temp\service.csv # Import csv file
Get-Process | Export-Clixml -Path C:\temp\good.xml # Export process to XML file
Get-Service | Out-File -FilePath C:\temp\test.txt # Output a txt file
Get-Content C:\temp\test.txt # Get the content from a file
Get-Service | ConvertTo-Html -Property name,status | Out-File C:\temp\test.htm # Export to a HTML file
Get-Service | Stop-Service -WhatIf Get-Service | Stop-Service -Confirm # Add what if or confirm for dangerous operation
Get-Module -ListAvailable # List all the available modules in Powershell
Chapter 4: Powershell – Objective (用于管理的对象)
Get-Service | Select -Property name,status
Get-ChildItem | select -Property name, Length | sort -Property lenth
Get-EventLog -LogName System -Newest 5
Get-EventLog -LogName System -Newest 5 | select -Property EventID, TimeWritten ,Message | sort -Property timewritten | ConvertTo-Html | Out-File c:\temp\error.html
Get-Service | where {$_.status -eq “running”} # Get the running service, $ is a Variables
Get-Service | where {$PSItem.status -eq “running” -and $_.name -like “b*”}
Chapter 4: Powershell – The Pipeline:Depper (深入探讨管道)
Incorrect input as -WhatIf is a serive name

PS C:\Windows\system32> get-process Calculator
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
——- —— —– —– —— — — ———–
566 28 19064 380 0.72 9840 1 Calculator
PS C:\Windows\system32> get-process Calculator | dir
Directory: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1906.55.0_x64__8wekyb3d8bbwe
Mode LastWriteTime Length Name
—- ————- —— —-
-a—- 12/7/2019 5:56 PM 4099584 Calculator.exe
Get-ADcomputer -filter * | gm # Get
PS C:\Windows\system32> get-service -name bits | select -Property name, status
Name Status
—- ——
bits Running
PS C:\Windows\system32> get-service -name bits | select -Property naem, stitus
naem stitus
Create new property
PS C:\Windows\system32> get-service -name bits | select -Property naem, stitus |gm
TypeName: Selected.System.ServiceProcess.ServiceController
Name MemberType Definition
—- ———- ———-
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
naem NoteProperty object naem=null
stitus NoteProperty object stitus=null