= PowerShell #Search command > get-command #Search alias of command > get-alias | where-object {$_.Definition -match "Get-Command"} #help >get-help get-alias >get-help get-alias -detailed #date > get-date > (Get-Date).GetType() > (Get-Date).Year # get-meber is for getting member information of object. > Get-Date | Get-Member > Get-Date | Get-Member -MemberType Method > Get-Date | Get-Member -MemberType Property # system information. > Get-EventLog -logName system -newest 10 #sort > Get-EventLog -logName system -newest 10 | Sort-Object eventID # Get-childItem for seeing the property > Get-ChildItem *.* | Select-Object Name, Length > Get-ChildItem *.* | Select-Object Name, Length | Sort-Object Length # for getting service > Get-Service > get-service | Where-Object {$_.Status -eq "Stopped"} #Grouping Get-ChildItem *.* | Group-Object Extension # Execute script > cd C:\misc > Get-ExecutionPolicy > Set-ExecutionPolicy RemoteSigned > notepad sample1.ps1 if ( Test-Path gtest.txth ) { Write-Host "test.txt exist" } else { Write-Host "test.txt does not exist" } > ./sample1.ps1 #sample script > notepad sample2.ps1 Write-Host $args[0] > ./sample2.ps1 "A" #Pass the value as ref > notepad sample3.ps1 function Test-ref([ref]$x,$y) { $x.value = 5 $y=5 } $x=1 $y=1 Test-ref([ref]$x) $y write-host $x,$y > ./sample3.ps1 # register function > notepad C:\Users\Owner\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 Set-Variable -Scope "Global" -Option "Constant" -Name "GlobalScripts" -Value "$PSHome\Scripts"; Set-Variable -Scope "Global" -Option "Constant" -Name "Scripts" -Value ("{0}\WindowsPowerShell\Scripts" -f [Environment]::GetFolderPath("MyDocuments")); function Execute-Scripts { param ([String]$scriptsFolderPath) if (Test-Path $scriptsFolderPath) { Get-ChildItem $scriptsFolderPath -Include "*.ps1" -Recurse -Force | % { &($_.FullName); }; } } Execute-Scripts $GlobalScripts; Execute-Scripts $Scripts; > notepad C:\Users\Owner\Documents\WindowsPowerShell\Scripts\Hoge.ps1 function global:Hoge { return "HogeHoge"; } #restart poweshell > Hoge