notes, references

August 9, 2010

powershell prevent output

Filed under: powershell — Tags: — karthik @ 9:59 pm

To prevent output of a command from being displayed you can assign it to a variable or pipe it to out-null

c:\ > Get-Services | out-null

check help

c:\ > Get-Help  out-null

August 6, 2010

Powershell how to get help

Filed under: powershell — Tags: — karthik @ 3:09 pm

MSDN PowerShell

Technet PowerShell

Computerperformance.co.uk

Powershell.com

Just type help at the powershell prompt

PS C:\>help
PS C:\>help <string>
PS C:\>Get-Help <string>    (the string can be a wild card)

useful help topics

PS C:\>help get-member
PS C:\>help get-command
PS C:\>help where-object
PS C:\>help about-object

powershell general usage

Filed under: powershell — Tags: — karthik @ 8:28 am
  • you need to provide path for the ps script for it to work; dot-source it even if in the current directory: .\test.ps1
  • 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

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.