Episode 10 - WinRM will power PowerShell Remoting in V2

A Podcast about Windows PowerShell.

Listen:

Introduction

  • We've had over 5,400 downloads so far! Thanks, everyone!

News

  • PowerShell remoting will work via WinRM according to thisfrom the Scripting NewsWire
    • "Something else to consider. Sometime before the end of the year an upgraded CTP (Community Technology Preview) version of Windows PowerShell will be released, an upgrade that will enable you to run most Windows PowerShell cmdlets against remote computers. The catch? This new version of Windows PowerShell also relies on WinRM as its remote transport protocol. If you’re interested in using Windows PowerShell to manage remote computers you’ll need to download and install WinRM on your Windows XP and Windows Server 2003 machines."
  • New Blog: PowerShell Pro
    • "PowerShell Pro is a community devoted to compiling the leading resources needed in achieving that goal. Whether you are an advanced PowerShell user or just starting out, PowerShell Pro is dedicated to presenting information required for your success."
    • Lots of content. Nice format.
  • Powershell "Yahoo Pipe"created by Jaykul.
    • Aggregate RSS feed containing articles from tons of PowerShell blogs.
  • Another company "Gets it": IBM
    • Dale Lane in the UK has written on his blog about PowerShell Cmdlets he's developing for IBM WebSphere.
  • Overview of next PS Virtual User's Group - Dec 4th
    • Oisin presenting talk about cmdlet development, new foundations in pscx, and touching on providers
      and paths in PowerShell

Cmdlet of the week: Set-PSDebug

Check out Keith Hill's article on Set-PSDebug: Effective PowerShell Item 5: Use Set-PSDebug -Strict In Your Scripts - Religiously

  • dynamic languages like PS allow you to use a variable without initializing it
  • equivalent to "option explicit" in Vbscript
  • ERROR: set-psdebug -strict; $foo += "bar"
  • NO ERROR: $foo = "hello" ; $foo += "bar"

Resources

Tips

  • Hal talks about working with CSV and other forms of structured text.
  • Source: Import-WebCsv
# Import a URL as CSV and write output to pipeline
Function Import-WebCsv {
    Param ( $url )

    $tempFile = [System.IO.Path]::GetTempFileName()
    $webClient = new-object System.Net.WebClient
    $webClient.DownloadFile($url,$tempFile)
    $data = import-csv $tempFile
    [System.IO.File]::Delete($tempFile)
    write-output $data
}

PowerShell Moments

  • "netsh dhcp server SERVERNAME scope SCOPEID add reservedip 10.10.0.1
    00c0ffee0001"
  • $vms = import-csv ipandmacs.csv
    $vms | % {"netsh dhcp server myserver scope myscope " + $_.IP + " "+ $_.Mac} | out-file createdhcpreservations.cmd
  • There is a bigip.conf file that for nodes at least looks like this
  • node 10.10.10.1 {
    limit 1
    }
    the limit has to do with how many connections per host you can have.
    Well i banged out this config file using Powershell 1..216 | % {"node 10.10.10." + $_ + " {`n   limit 1`n}"} | out-file
    bigipconf.txt - Thanks Andy!

One-Liners

  •  $ErrorActionPreference = "silentlycontinue"
  • gc scott.txt | %{$u=$_; trap {"$u,deleted"} if(get-qaduser $_ -disabled){"$_,disabled"}else{"$_,active"}} | out-file “User Status.csv”

Gotchas

Closing

Thanks for listening! Keep the feedback coming, we really love hearing from you. Also don't forget to write reviews and vote for us on iTunes, Podcast Alley and wherever else you may find us.

About the Author

Jonathan Walz

Since March 2007, Jonathan Walz has been the co-host and technical brains for the PowerScripting Podcast. Conceived as a radio show for the PowerShell community, the podcast is the longest-lived PowerShell show in existence, and has featured dozens of weekly guests.