PowerScripting Podcast – Episode 10

13 10 2007

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 this from 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.


    Actions

    Information

    3 responses

    15 10 2007
    The PowerShell Guy : PowerShell News

    [...] and more news PowerShell news you can find in  another PowerScripting Podcast – Episode 10 . [...]

    19 10 2007
    Joe Brinkman

    I noticed that you recently changed your podcast filenames. Please stick with a standard naming structure (pick one, any one) since it is much easier to find them on my MP3 player when they are all together and sequentially ordered.

    20 10 2007
    Jonathan Walz

    Hi Joe,

    Sorry about that it was totally a nube podcaster mistake. I will try to consistently name the files in the format PSPoscast-xxx. I hope this will work for you on your mp3 player. I would like to go back and change the existing file names but I think this would cause some podcatchers to re-download those episodes which may be annoying for people.

    Thanks,
    Jonathan

    Leave a comment