Episode 9 - PowerShell V2 news is coming in November

A Podcast about Windows PowerShell.

Listen:

Introduction

  • Thanks to //o// and Kirk at Poshoholic for mentioning us on their blogs. We loved Kirk's post about namespaces with the Star Trek references.  That's the Trouble with Tribbles!

News

  • According to Bruce Payette in this post, details of PowerShell V2's upcoming features will be released in November at ITForum!
  • From $hay@Israel' s blog: There is a new book titled "Windows PowerShell in Practice" that is being worked on by Jim Truher and //o//.  It will be published by Manning and will cover topics such as, the PowerShell SDK (writing cmdlets, providers etc) advanced scripting techniques and domain specific examples.
  • Citrix, Citrix, and more Citrix!  Brandon Shell has gifted us with a veritable cornucopia of sixteen (16!) Citrix management functions such as:
    • Get-CitrixFarm
    • Publish-CitrixApplication
  • Keith Hill and //o// will be a guest speaker in the first Windows PowerShell Virtual User Group Meeting (From Marco Shaw's blog)
  • Phoul from the #Powershell IRC channel has a new blog up(http://insecure-complexity.com/).  In his own words:
    • "Especially to the new PowerShell users. I'm writing a blog that will be focused around my findings in my experience learning PowerShell. It will have scripts and tutorials and some neat tips n tricks after I get a little more acquainted with PowerShell. For now it has a profile example and a useful script for signing your scripts."

Cmdlet of the week

  • We were going to do Set-PSDebug but Hal didn't do his homework.  Instead, we gave the royal treatment to Get-Service!

Resources - Got a ton for ya this week:

Tips

  • PowerShell is a scripting engine AND a shell
    • Don Jones had an article about this in Technet (October Issue) when it comes out online it should be here
    • Don Jones Technet article "Scripting One Line at a Time".  This talks about how you go about building a script based on the interactive nature of PowerShell
  • $profile discussion part 2
    1. Gather your reusable bits into functions. Since they may be shared, be sure to comment them well.
    2. Categorize these functions by type.
    3. Organize each category of functions into a unique .PS1 file. I recommend prepending the filenames with "lib-" or similar.
    4. Place all the files in your profile directory, or on a file server, and dot-source them in your profile using something like this:

# place in your profile to load shared scripts
New-Psdrive -name Scripts -Psprovider FileSystem -root \serverscripts
Get-ChildItem Scripts:lib-*.ps1 | Foreach-Object { . $_ }

Powershell Moments

  • Hal shares his frustration having to work with an NT 4.0 domain and how many ADSI queries don't work against it, even if he uses the WinNT addressing scheme, as opposed to LDAP.
  • Jonathan shares how easy the Quest cmdlets make it to "copy" users from one domain to another. His code was similar to this:
    • Connect-QADService -service 'domain.dev'
    • $users - GetQADUser -SearchRoot 'OU=Users,DC=domain,DC=dev'
    • Disconnect-QADService
    • Connect-QADService -service 'domain.tst'
    • $users | %{new-qaduser -name $_.Name -ParentContainer 'OU=Users,DC=domain,DC=tst' -SamAccountName $_.LogonName -description $_.description -displayname $_.DisplayName -firstName $_.firstname -lastname $_.lastname -UserPrincipalName $_.name}

One-liners

# extract part of a filename

dir | Foreach-Object { $_.name.substring(0,8) }

Gotchas

  • From Poshoholic- If you convert any string to a boolean value in PowerShell, the resulting boolean value will be boolean True.  (With the exception of empty strings, which are $false.)

Powershell challenge

  • Hal asked if anyone knows how to set SACLs on remote files.  Not file ACLs but security auditing stuff.  Turns out it might be much easier than he thought (using set-acl on a UNC path), but if you've got any code to share that's great!

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.