Create scripts to automate common tasks
Add parameters to scripts
Reuse code with functions
Share code using modules
Slowly but surely you are becoming a
PowerShell professional
–
You know pipelines and filtering:
Get-ChildItem -Path C:\Windows\System32 -File |
Where-Object { $_.Extension } |
Select-Object -Property Extension,Size |
Group-Object -Property Extension -NoElement |
Sort-Object -Property Count -Descending
An array or objects is similar to a database table
Where-Object
filters objects (rows)Select-Object
filters properties (fields)Remember: Everything is an object
–
You know how to help yourself:
Get-ChildItem -?
Get-Help Get-ChildItem -Full
Get-Command *-Item
'some_string' | Get-Member
Jeffrey Snover’s favourite cmdlet is Get-Help
Run Update-Help
once in a while
–
You know how to write functions:
function ConvertTo-Base64 {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Data
)
[Convert]::ToBase64String(
[System.Text.Encoding]::UTF8.GetBytes($Item)
)
}
Naming scheme is Verb-Noun
(singular)
Get-Verb
displays approved verbs