Dup Ver Goto 📝

PsBasics

PT2/aw/lang/ps does not exist
To
32 lines, 113 words, 896 chars Page 'PsBasics' does not exist.
Get-Command
Get-Help Get-Command
Get-Help Get-Command -Online
Get-Command New-SmbShare | Select-Object Name
Get-Command New-SmbShare | Format-List
Get-Command *Smb*

New-Guid
New-Guid | Write-Host
New-Guid | ForEach { $_.Guid } | clip

Enabling scripts

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned # allows local scripts

Strings, Patterns, Wildcards

Get-ChildItem -Path "C:\Windows\*" -Filter *.exe
Get-ChildItem -Path "C:\Windows\*" | Where-Object { $_.Name -Match "^se" } # find files whose names start with "se"

the latter is the equivalent of the bash

ls /c/Windows/* | grep ^se

String Manipulation

"hello world".Split(" ")               # hello, world
"hello/world/mr.flibble".Split("[/.]") # hello, world, mr, flibble -- argument to Split is a regex
"a/b/c/d".Split("/").Count             # 4