# set powershell execution policy for running scripts
# Script Execution Policy, is it allowed to run a script?
Get-ExecutionPolicy -List | Format-Table -AutoSize
# set execution policy
Set-ExecutionPolicy RemoteSigned
# run a powershell script
powershell.exe -executionpolicy bypass ./<filename.ps1>
comment in a powershell script: # (Hashtag)
# query a services
get-service * | where status -like running
# output to a file
.... | out-file -filepath <path/file>
.... | out-file -filepath <path/file> -append
.... | tee-object -filepath <path/file>
.... | tee-object -filepath <path/file> -append
# formating powershell outputs
# output the last 10
.... | select-object -first 10
# format output
.... | format-table -autosize
# create a file on the desktop
.... | out-file -filepath $env:USERPROFILE\Desktop\<file>
# do a paging like '| more'
.... | out-host -paging
# display graphical
.... | Out-Gridview
# like echo on command line
write-host <command>
write-output 'text'