More Notes

Text Editor (Notepad++)

    Block Select (Alt+Select)

    Macros

    

    Example 

        $date = get-date 2/25/2010

        $date = $date.AddHours(8)

        $Blahpathlist = gci "\\server\Backup$\Full Backups" -include *.sqb -Recurse | where {$_.LastWriteTime -ge $date } | select FullName

        $Blahpathlist > BlahPathlist.txt

        Macro1 Use a text editor to remove trailing spaces from each line

        Macro2 format the sql query

            

Powershell

    New in Powershell 2 (Windows Remote Management - WinRM)

        GUI IDE

        Out-Grid

        Script Cmdlets

    Additionals tools

        safaribooksonline.com

        Quest Active Roles powershell (Nice cmdlets)

        less.exe (when you want to be able to read help files)

    tab completion

    piping

    

    Important cmdlets

        get-help

            how to read (syntax)

            -full

            -examples

            get-help about

            get-help get-p

            Get-Help -Online Get-Member

            

        get-command

            get-command dir

            get-command Get-ChildItem

            Get-Command select

            Get-Command -CommandType function

            get-command -verb get

            get-command -noun job

            get-command | where {$_.Parameters.ContainsKey("Credential")}

            Get-Command -Module Citrix.XenApp.Commands | where {$_.Parameters.ContainsKey("Credential")}

        get-member

        

    Variables

        get-help *variable*

        Built-in Variables

        get-variable

        $env:path

        $foo = "blah"

        [string]$foo = "blah"

        $foo | gm

        $a=8

        $a.gettype()

        $a | gm

        

    Array

        get-help array | more 

        $b = 1,2,3,"blah"

        $b.gettype()

        

    Hashes

         get-help hash | more

         $hash=@{'Home'="123 main street";'Work'="456 Blah Ave"}

         $hash

         $hash['Work']

         

    Objects

        properties

        methods

        events

    Examples

        Get-ExecutionPolicy

        Set-ExecutionPolicy

        get-eventlog -newest 10  

        get-process

        $c = 1..10 (.. range operator)

        $c

        $c | foreach {$_ * 2}

        

    Fancy

        Get-PSProvider

        cd hklm:

        Get-Command cd

        get-command c:

        Set-Location hklm:

        cd function:

        dir

        function env: {Set-Location env:}

        Get-Content Function:\TabExpansion

        env:

        dir (gci)

        measure-command

        measure-object

        Get-WmiObject win32_logicaldisk | gm

        Get-WmiObject win32_logicaldisk | select DeviceID, Compressed

        $cred = Get-Credential

        Get-WmiObject -ComputerName cspcdc02 -Credential $cred win32_logicaldisk | select DeviceID, __SERVER, Compressed