powershell general usage

  • you need to provide path for the ps script for it to work; dot-source it even if in the current directory: .\test.ps1 (this is like in a linux shell)
  • NOT case-sensitive; nothing is including variable names defined by you
  • Variable
    • prefix name with ‘$’ symbol
    • $v = “hello” and use it as $v everywhere
    • not when you use Set-Variable
    • no need to specify type; if required [int]$number = 1
  • functions have to be defined before you can use them, literally the order in the ps file
  • End of line is end of command; multi-line use backtick ` to indicate the command continues on next line (no space after backtick)
  • Semi-colon ; can be used to separate multiple commands on the same line
  • Comment character #; multi-line comments <# ……. #>
  • [] brackets can be used to specify the object. [String] represents the string object
  • filtering – select-string, select-object (search web for “powershell filtering”)
  • formatting – format-list (shortcut fl), format-table (ft), format-wide (fw)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.