<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The Lonely Administrator</title>
	
	<link>http://jdhitsolutions.com/blog</link>
	<description>Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.</description>
	<lastBuildDate>Fri, 17 May 2013 19:00:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JeffsScriptingBlogAndMore" /><feedburner:info uri="jeffsscriptingblogandmore" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Friday Fun: A PowerShell Tickler</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/QQfj1NK3iH0/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/friday-fun-a-powershell-tickler/#comments</comments>
		<pubDate>Fri, 17 May 2013 19:00:29 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[Friday Fun]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Import-CSV]]></category>
		<category><![CDATA[module]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3042</guid>
		<description><![CDATA[I spend a lot of my day in the PowerShell console. As you might imagine, I often have a lot going on and sometimes it is a challenge to keep on top of everything. So I thought I could use PowerShell to help out. I created a PowerShell tickler system. Way back in the day [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L2VsbW8uanBnI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-medium wp-image-3043" alt="elmo" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/elmo-221x300.jpg" width="221" height="300" /></a>I spend a lot of my day in the PowerShell console. As you might imagine, I often have a lot going on and sometimes it is a challenge to keep on top of everything. So I thought I could use PowerShell to help out. I created a PowerShell tickler system. Way back in the day a tickler system was something that would give you a reminder about an impending event or activity. What I decided I wanted was a tickler that would display whenever I started PowerShell.</p>
<p>This doesn&#8217;t replace my calendar and task list, but it let&#8217;s me see events I don&#8217;t want to miss right from PowerShell. As I worked through this idea I ended up with a PowerShell module, MyTickle.psm1, that has a number of functions to managing the tickle events, as I call them. From PowerShell I can get events, add, set and remove. I thought the module would make a good Friday Fun post because it certainly isn&#8217;t a high impact project but it offers some ideas on building a module and functions that I hope you&#8217;ll find useful.</p>
<p>The module for right now is a single file. Here&#8217;s the file and below I&#8217;ll talk about.</p><pre class="crayon-plain-tag">#requires -version 3.0

#  ****************************************************************
#  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *
#  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *
#  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *
#  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *
#  ****************************************************************

#MYTICKLE.PSM1
#Last updated 5/17/2013

#region Define module variables
#This should be the WindowsPowerShell folder under your Documents folder
$profileDir = Split-Path $profile

#the path to the tickle csv file
$TicklePath = Join-Path -Path $profileDir -ChildPath "mytickler.csv"

#the default number of days to display
$TickleDefaultDays = 7 
#endregion

#region Define module functions
Function Get-TickleEvent {

.Synopsis
Get Tickle Events
.Description
Get tickle events by id or name. The default behavior is to get all events in
date order. You can specify a range of ID numbers and use wildcards with the 
event names. Use the Expired switch to get all tickle events that have already 
occurred. 

The command will not throw an exception if no matching tickle events are found.

[cmdletbinding(DefaultParameterSetname="ALL")]
Param(
[Parameter(Position=0,ParameterSetName="ID")]
[int[]]$Id,
[Parameter(Position=0,ParameterSetName="Name")]
[string]$Name,
[Parameter(Position=0,ParameterSetName="Expired")]
[switch]$Expired,
[ValidateScript({Test-Path $_} )]
[string]$Path=$TicklePath
)

Write-Verbose "Importing events from $Path"

Switch ($pscmdlet.ParameterSetName) {
 "ID"      {
            Write-Verbose "by ID" 
            $filter = [scriptblock]::Create("`$_.id -in `$id")  }
 "Name"    { 
            Write-Verbose "by Name"
            $filter = [scriptblock]::Create("`$_.Event -like `$Name") }
 "Expired" { 
            Write-Verbose "by Expiration"
            $filter = [scriptblock]::Create("`$_.Date -lt (Get-Date)") }
 "All"     { 
            Write-Verbose "All"
            $filter = [scriptblock]::Create("`$_ -match '\w+'") }

} 

#import CSV and cast properties to correct type
Import-CSV -Path $Path | 
Select @{Name="ID";Expression={[int]$_.ID}},
@{Name="Date";Expression={[datetime]$_.Date}},
Event,Comment | where $Filter | Sort date

} #Get-TickleEvent

Function Set-TickleEvent {

.Synopsis
Set a tickle event
.Description
This command will update the settings for a tickle event. You can update the
event name, date or comment. The easiest way to use this is to pipe an tickle
event to this command.

[cmdletbinding(SupportsShouldProcess,DefaultParameterSetName="Inputobject")]
Param(
[Parameter(Position=0,Mandatory,HelpMessage="Enter the tickle event id",ParameterSetName="ID")]
[int]$Id,
[Parameter(Position=1,ValueFromPipeline,ParameterSetname="Inputobject")]
[object]$Inputobject,
[datetime]$Date,
[string]$Event,
[string]$Comment,
[ValidateScript({Test-Path $_} )]
[string]$Path=$TicklePath,
[switch]$Passthru
)
Begin {
    write-verbose "Using $($PSCmdlet.ParameterSetName) parameter set"
}
Process {

#if ID only then get event from CSV
Switch ($pscmdlet.ParameterSetName) {
 "ID" {
    Write-Verbose "Getting tickle event id $ID"
    $myevent = Get-TickleEvent -id $id
   }
 "Inputobject" {
    Write-Verbose "Modifying inputobject"
    $myevent = $Inputobject
 }
} #switch

#verify we have an event to work with
if ($myevent) {
    #modify the tickle event object
    write-verbose ($myevent | out-string)

    if ($Date) {
      Write-Verbose "Setting date to $date"
      $myevent.date = $Date
    }
    if ($Event) {
      Write-Verbose "Setting event to $event"
      $myevent.event = $Event
    }
    if ($comment) {
      Write-verbose "Setting comment to $comment"
      $myevent.comment = $comment
    }
    write-verbose "Revised: $($myevent | out-string)"

    #find all lines in the CSV except the matching event
    $otherevents = get-content -path $Path | where {$_ -notmatch "^""$($myevent.id)"} 
    #remove it
    $otherevents | Out-File -FilePath $Path -Encoding ascii 

    #append the revised event to the csv file
    $myevent | Export-Csv -Path $Path -Encoding ASCII -Append -NoTypeInformation

    if ($passthru) {
        $myevent
    }
}
else {
    Write-Warning "Failed to find a valid tickle event"
}

} #process

} #Set-TickleEvent

Function Add-TickleEvent {

.Synopsis
Add a tickle event
.Description
This command will create a new tickle event. If the CSV file referenced by the
TicklePath variable does not exist, it will be created. You must enter an event 
name and date.

[cmdletbinding(SupportsShouldProcess)]

Param (
[Parameter(Position=0,ValueFromPipelineByPropertyName,Mandatory,HelpMessage="Enter the name of the event")]
[string]$Event,
[Parameter(Position=1,ValueFromPipelineByPropertyName,Mandatory,HelpMessage="Enter the datetime for the event")]
[datetime]$Date,
[Parameter(Position=2,ValueFromPipelineByPropertyName)]
[string]$Comment,
[ValidateNotNullorEmpty()]
[string]$Path=$TicklePath,
[switch]$Passthru
)

Begin {
    #verify the path and create the file if not found
    if (! (Test-Path $Path)) {
        Write-Verbose "Creating a new file: $Path"
        Try {
         '"id","Date","Event","Comment"' | 
         Out-File -FilePath $Path -Encoding ascii -ErrorAction Stop
        }
        Catch {
            Write-Warning "Failed to create $Path"
            Write-Warning $_.Exception.Message
            $NoFile = $True
        }
    }
}

Process {
if ($NoFile) {
    Write-Verbose "No CSV file found."
    #bail out of the command
    Return
}

#get last id and add 1 to it
[int]$last = Import-Csv -Path $Path | 
Sort {$_.id -AS [int]} | Select -last 1 -expand id
[int]$id = $last+1

$hash=[ordered]@{
  ID = $id
  Date = $date
  Event = $event
  Comment = $comment
}
Write-Verbose "Adding new event"
Write-Verbose ($hash | out-string)

$myevent = [pscustomobject]$hash
$myevent | Export-Csv -Path $Path -Append -Encoding ASCII -NoTypeInformation
if ($passthru) {
    $myevent
}
} #process

} #Add-TickleEvent

Function Remove-TickleEvent {

.Synopsis
Remove a tickle event
.Description
Remove one or more events from the tickle file. This will overwrite the current
file so you might want to back it up first with Backup-TickleFile.
.Example
PS C:\> get-ticklevent -expired | remove-tickleevent

[cmdletbinding(SupportsShouldProcess,DefaultParameterSetName="Inputobject")]
Param(
[Parameter(Position=0,Mandatory,HelpMessage="Enter the tickle event id",ParameterSetName="ID")]
[int]$Id,
[Parameter(Position=1,ValueFromPipeline,ParameterSetname="Inputobject")]
[object]$Inputobject,
[ValidateScript({Test-Path $_} )]
[string]$Path=$TicklePath
)

Process {

    #if ID only then get event from CSV
    Switch ($pscmdlet.ParameterSetName) {
     "ID" {
        Write-Verbose "Getting tickle event id $ID"
        $myevent = Get-TickleEvent -id $id
       }
     "Inputobject" {
        Write-Verbose "Identifying inputobject"
        $myevent = $Inputobject
     }
    } #switch

    #verify we have an event to work with
    if ($myevent) {
        Write-Verbose "Removing event"
        Write-Verbose ($myEvent | Out-String)
        if ($pscmdlet.ShouldProcess(($myEvent | Out-String))) {
        #find all lines in the CSV except the matching event
        $otherevents = Get-Content -path $Path | where {$_ -notmatch "^""$($myevent.id)"} 
        #remove it
        $otherevents | Out-File -FilePath $Path -Encoding ascii 
        }
    } #if myevent

} #process

} #Remove-TickleEvent

Function Show-TickleEvent {

.Synopsis
Display Tickle events in the console
.Description
This command gets upcoming tickle events and writes them to the console using
Write-Host. Use this command in your PowerShell profile script.

[cmdletbinding()]
Param(
[Parameter(Position=0)]
[ValidateScript({Test-Path $_})]
[string]$Path=$TicklePath,
[Parameter(Position=1)]
[ValidateScript({$_ -ge 1})]
[int]$Days = $TickleDefaultDays
)

#import events from CSV file
$events = Import-Csv -Path $Path

#get upcoming events within 7 days sorted by date
$upcoming = $events | 
where {
 #get the timespan between today and the event date
 $ts = (New-TimeSpan -Start (Get-Date) -end $_.Date).TotalHours 
 #find events less than the default days value and greater than 0
 Write-Verbose $ts
 $ts -le ($Days*24) -AND $ts -gt 0
 } |
Add-Member -MemberType ScriptProperty -Name Countdown -value {New-TimeSpan -start (Get-Date) -end $this.date} -PassThru -force|
sort CountDown

if ($upcoming) {
#how wide should the box be?
#get the length of the longest line
$l = 0
foreach ($item in $upcoming) {
 #turn countdown into a string without the milliseconds
  $count = $item.countdown.ToString()
  $time = $count.Substring(0,$count.lastindexof("."))
  #add the time as a new property
  $item | Add-Member -MemberType Noteproperty -name Time -Value $time
  $a = "$($item.event) $($item.Date) [$time]".length
  if ($a -gt $l) {$l = $a}
  $b = $item.comment.Length
  if ($b -gt $l) {$l = $b}
}

[int]$width = $l+5

$header="* Reminders $((Get-Date).ToShortDateString())"

#display events
Write-Host "`r"
Write-host "$($header.padright($width,"*"))" -ForegroundColor Cyan
Write-Host "*$(' '*($width-2))*" -ForegroundColor Cyan

foreach ($event in $upcoming) {

  if ($event.countdown.totalhours -le 24) {
    $color = "Red"
  }
  elseif ($event.countdown.totalhours -le 48) {
    $color = "Yellow"
  }
  else {
    $color = "Green"
  }

  #define the message string
  $line1 = "* $($event.event) $($event.Date) [$($event.time)]"
  if ($event.comment -match "\w+") {
   $line2 = "* $($event.Comment)"
   $line3 = "*"
  }
  else {
   $line2 = "*"
   $line3 = $null
  }

$msg = @"
$($line1.padRight($width-1))*
$($line2.padright($width-1))*
"@

if ($line3) {
    #if there was a comment add a third line that is blank
    $msg+="`n$($line3.padright($width-1))*"
}

  Write-Host $msg -ForegroundColor $color

} #foreach

Write-host ("*"*$width) -ForegroundColor Cyan
Write-Host "`r"
} #if upcoming events found
else {
  $msg = @"

**********************
* No event reminders *
**********************

"@
  Write-host $msg -foregroundcolor Green
}

} #Show-TickleEvent

Function Backup-TickleFile {

.Synopsis
Create a backup of the tickle file
.Description
This command will create a backup copy of the tickle CSV file. The default path
is the same directory as the tickle file. You might want to backup the tickle
file before removing any events.

[cmdletbinding(SupportsShouldProcess)]
Param(
[ValidateScript({Test-Path $_} )]
[string]$Path=$TicklePath,
[ValidateScript({Test-Path $_} )]
[string]$Destination = (Split-Path $TicklePath),
[switch]$Passthru
)

Try {
    $ticklefile = Get-Item -Path $path
    $backup = Join-Path -path $Destination -ChildPath "$($ticklefile.basename).bak"
    Write-Verbose "Copying $path to $backup"
    $ticklefile | Copy-Item  -Destination $backup -ErrorAction Stop -PassThru:$Passthru
}
Catch {
    Write-Warning "Failed to backup file"
    Write-Warning $_.exception.message
}
} #Backup-TickleFile
#endregion

#region Define module aliases
Set-Alias -Name gte -value Get-TickleEvent
Set-Alias -name ate -Value Add-TickleEvent
Set-Alias -name rte -Value Remove-TickleEvent
Set-Alias -name ste -Value Set-TickleEvent
Set-Alias -name shte -Value Show-TickleEvent
Set-Alias -name btf -Value Backup-Ticklefile
#endregion

Export-ModuleMember -Function * -Variable TicklePath,TickleDefaultDays -Alias *</pre><p>You should be able to copy the code from the WordPress plugin and paste it into a script file locally. You can call it whatever you want just remember to use a .psm1 file extension. The module uses some PowerShell 3.0 features like ordered hashtables but you could revise to have it run in PowerShell 2.0. Fundamentally it should work in both versions.</p>
<p>The events are stored in a CSV file that I reference with a module variable, $TicklePath. The default is a file called mytickler.csv which will be in your WindowsPowerShell folder under Documents. The module also defines a variable called $TickleDefaultDays, with a default value of 7. This displayed events to those that fall within that range. To use, I added these lines to my PowerShell profile.</p><pre class="crayon-plain-tag">import-module c:\scripts\mytickle.psm1
show-tickleevent</pre><p>The result, is that when I launch a new PowerShell session I see something like this (the message about help updates is from something else so disregard):<br />
<a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L3Nob3ctdGlja2xlLnBuZyN1dG1fc291cmNlPWZlZWQmYW1wO3V0bV9tZWRpdW09ZmVlZCZhbXA7dXRtX2NhbXBhaWduPWZlZWQ="><img class="aligncenter size-large wp-image-3044" alt="show-tickle" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/show-tickle-1024x444.png" width="625" height="270" /></a></p>
<p>Here&#8217;s how it works.</p>
<p>The Show-TickleEvent function imports events from the CSV file that will happen within the next 7 days. Each object also gets an additional property that is a timespan object for how much time remains. The function then parses event information and constructs a &#8220;box&#8221; around the events.</p><pre class="crayon-plain-tag">#how wide should the box be?
#get the length of the longest line
$l = 0
foreach ($item in $upcoming) {
 #turn countdown into a string without the milliseconds
  $count = $item.countdown.ToString()
  $time = $count.Substring(0,$count.lastindexof("."))
  #add the time as a new property
  $item | Add-Member -MemberType Noteproperty -name Time -Value $time
  $a = "$($item.event) $($item.Date) [$time]".length
  if ($a -gt $l) {$l = $a}
  $b = $item.comment.Length
  if ($b -gt $l) {$l = $b}
}

[int]$width = $l+5

$header="* Reminders $((Get-Date).ToShortDateString())"

#display events
Write-Host "`r"
Write-Host "$($header.padright($width,"*"))" -ForegroundColor Cyan
Write-Host "*$(' '*($width-2))*" -ForegroundColor Cyan

#get upcoming events within 7 days sorted by date
$upcoming = $events |
where {
#get the timespan between today and the event date
$ts = (New-TimeSpan -Start (Get-Date) -end $_.Date).TotalHours
#find events less than the default days value and greater than 0
Write-Verbose $ts
$ts -le ($Days*24) -AND $ts -gt 0
} |
Add-Member -MemberType ScriptProperty -Name Countdown -value {New-TimeSpan -start (Get-Date) -end $this.date} -PassThru -force |
sort CountDown</pre><p>I set a foreground color depending on how imminent the event is and then write each event to the console, wrapped in my border.</p><pre class="crayon-plain-tag">#define the message string
  $line1 = "* $($event.event) $($event.Date) [$($event.time)]"
  if ($event.comment -match "\w+") {
   $line2 = "* $($event.Comment)"
   $line3 = "*"
  }
  else {
   $line2 = "*"
   $line3 = $null
  }

$msg = @"
$($line1.padRight($width-1))*
$($line2.padright($width-1))*
"@

if ($line3) {
    #if there was a comment add a third line that is blank
    $msg+="`n$($line3.padright($width-1))*"
}

  Write-Host $msg -ForegroundColor $color</pre><p>I purposely used Write-Host so that I could color code events and because I didn&#8217;t want the profile to write anything to the pipeline. Because the module is loaded at the start of my PowerShell session, I can always run Show-TickleEvent and event specify a different number of days. If I want objects, then I can use the Get-TickleEvent function which will import the csv events based on a criteria like ID or name. The function uses parameter sets and I create a filter scriptblock depending on the parameter set.</p><pre class="crayon-plain-tag">Switch ($pscmdlet.ParameterSetName) {
 "ID"      {
            Write-Verbose "by ID" 
            $filter = [scriptblock]::Create("`$_.id -in `$id")  }
 "Name"    { 
            Write-Verbose "by Name"
            $filter = [scriptblock]::Create("`$_.Event -like `$Name") }
 "Expired" { 
            Write-Verbose "by Expiration"
            $filter = [scriptblock]::Create("`$_.Date -lt (Get-Date)") }
 "All"     { 
            Write-Verbose "All"
            $filter = [scriptblock]::Create("`$_ -match '\w+'") }

}</pre><p>When I import the CSV file, I add types to the properties because otherwise everything would be a string, and then pipe each object to my filter.</p><pre class="crayon-plain-tag">#import CSV and cast properties to correct type
Import-CSV -Path $Path | 
Select @{Name="ID";Expression={[int]$_.ID}},
@{Name="Date";Expression={[datetime]$_.Date}},
Event,Comment | where $Filter | Sort Date</pre><p>These objects come in handy because they can be piped to Set-TickleEvent to modify values like event name, date or comment. Or I can pipe to Remove-TickleEvent to delete entries. The deletion process in essence finds all lines in the CSV file that don&#8217;t start with the correct id and creates a new file using the same name.</p><pre class="crayon-plain-tag">if ($pscmdlet.ShouldProcess(($myEvent | Out-String))) {
  #find all lines in the CSV except the matching event
  $otherevents = Get-Content -path $Path | where {$_ -notmatch "^""$($myevent.id)"} 
  #remove it
  $otherevents | Out-File -FilePath $Path -Encoding ascii 
 }</pre><p>Finally, after accidentally wiping out event files, I added a simple backup function copies the CSV file to the same directory but with a .BAK file extension. You could specify an alternate path, but it defaults to the WindowsPowerShell folder.</p>
<p>Hopefully I won&#8217;t miss important events again, of course assuming I add them to my tickler file. I&#8217;ll let you play with Add-TickleEvent to see how that works or you could always modify the CSV file with Notepad.</p>
<p>If you actually use this, I hope you&#8217;ll let me know.</p>
<p>[<strong>Note</strong>: due to a limitation in the syntax plugin I use, I removed the comment characters around the help in each function. You will need to add them back.]</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PUZyaWRheStGdW4lM0ErQStQb3dlclNoZWxsK1RpY2tsZXIraHR0cCUzQSUyRiUyRmpkaGl0c29sdXRpb25zLmNvbSUyRmJsb2clMkYyMDEzJTJGMDUlMkZmcmlkYXktZnVuLWEtcG93ZXJzaGVsbC10aWNrbGVyJTJG" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZnJpZGF5LWZ1bi1hLXBvd2Vyc2hlbGwtdGlja2xlci8mYW1wO3RpdGxlPUZyaWRheStGdW4lM0ErQStQb3dlclNoZWxsK1RpY2tsZXI=" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZnJpZGF5LWZ1bi1hLXBvd2Vyc2hlbGwtdGlja2xlci8mYW1wO3RpdGxlPUZyaWRheStGdW4lM0ErQStQb3dlclNoZWxsK1RpY2tsZXI=" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZnJpZGF5LWZ1bi1hLXBvd2Vyc2hlbGwtdGlja2xlci8mYW1wO3Q9RnJpZGF5K0Z1biUzQStBK1Bvd2VyU2hlbGwrVGlja2xlcg==" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1GcmlkYXkrRnVuJTNBK0ErUG93ZXJTaGVsbCtUaWNrbGVyJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2ZyaWRheS1mdW4tYS1wb3dlcnNoZWxsLXRpY2tsZXIv" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9RnJpZGF5K0Z1biUzQStBK1Bvd2VyU2hlbGwrVGlja2xlciZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9mcmlkYXktZnVuLWEtcG93ZXJzaGVsbC10aWNrbGVyLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErSStzcGVuZCthK2xvdCtvZitteStkYXkraW4rdGhlK1Bvd2VyU2hlbGwrY29uc29sZS4rQXMreW91K21pZ2h0K2ltYWdpbmUlMkMrSStvZnRlbitoYXZlK2ErbG90K2dvaW5nK29uK2FuZCtzb21ldGltZXMraXQraXMrYStjaGFsbGVuZ2UrdG8ra2VlcCtvbit0b3AuLi4=" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9RnJpZGF5K0Z1biUzQStBK1Bvd2VyU2hlbGwrVGlja2xlciZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9mcmlkYXktZnVuLWEtcG93ZXJzaGVsbC10aWNrbGVyLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErSStzcGVuZCthK2xvdCtvZitteStkYXkraW4rdGhlK1Bvd2VyU2hlbGwrY29uc29sZS4rQXMreW91K21pZ2h0K2ltYWdpbmUlMkMrSStvZnRlbitoYXZlK2ErbG90K2dvaW5nK29uK2FuZCtzb21ldGltZXMraXQraXMrYStjaGFsbGVuZ2UrdG8ra2VlcCtvbit0b3AuLi4=" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2ZyaWRheS1mdW4tYS1wb3dlcnNoZWxsLXRpY2tsZXIvJmFtcDt0aXRsZT1GcmlkYXkrRnVuJTNBK0ErUG93ZXJTaGVsbCtUaWNrbGVyJmFtcDtzdW1tYXJ5PUkrc3BlbmQrYStsb3Qrb2YrbXkrZGF5K2luK3RoZStQb3dlclNoZWxsK2NvbnNvbGUuK0FzK3lvdSttaWdodCtpbWFnaW5lJTJDK0krb2Z0ZW4raGF2ZSthK2xvdCtnb2luZytvbithbmQrc29tZXRpbWVzK2l0K2lzK2ErY2hhbGxlbmdlK3RvK2tlZXArb24rdG9wLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2ZyaWRheS1mdW4tYS1wb3dlcnNoZWxsLXRpY2tsZXIvJmFtcDt0aXRsZT1GcmlkYXkrRnVuJTNBK0ErUG93ZXJTaGVsbCtUaWNrbGVyJmFtcDtzdW1tYXJ5PUkrc3BlbmQrYStsb3Qrb2YrbXkrZGF5K2luK3RoZStQb3dlclNoZWxsK2NvbnNvbGUuK0FzK3lvdSttaWdodCtpbWFnaW5lJTJDK0krb2Z0ZW4raGF2ZSthK2xvdCtnb2luZytvbithbmQrc29tZXRpbWVzK2l0K2lzK2ErY2hhbGxlbmdlK3RvK2tlZXArb24rdG9wLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1GcmlkYXkrRnVuJTNBK0ErUG93ZXJTaGVsbCtUaWNrbGVyJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2ZyaWRheS1mdW4tYS1wb3dlcnNoZWxsLXRpY2tsZXIv" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9mcmlkYXktZnVuLWEtcG93ZXJzaGVsbC10aWNrbGVyLyZhbXA7dGl0bGU9RnJpZGF5K0Z1biUzQStBK1Bvd2VyU2hlbGwrVGlja2xlcg==" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZnJpZGF5LWZ1bi1hLXBvd2Vyc2hlbGwtdGlja2xlci8mYW1wO3RpdGxlPUZyaWRheStGdW4lM0ErQStQb3dlclNoZWxsK1RpY2tsZXI=" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2ZyaWRheS1mdW4tYS1wb3dlcnNoZWxsLXRpY2tsZXIvJmFtcDt0aXRsZT1GcmlkYXkrRnVuJTNBK0ErUG93ZXJTaGVsbCtUaWNrbGVy" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9mcmlkYXktZnVuLWEtcG93ZXJzaGVsbC10aWNrbGVyLw==" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3042" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/QQfj1NK3iH0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/friday-fun-a-powershell-tickler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/friday-fun-a-powershell-tickler/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=friday-fun-a-powershell-tickler</feedburner:origLink></item>
		<item>
		<title>Test 64-Bit Operating System</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/QiwElRGeP4o/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/test-64-bit-operating-system/#comments</comments>
		<pubDate>Thu, 16 May 2013 13:10:47 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[WMI]]></category>
		<category><![CDATA[Win32_OperatingSystem]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3036</guid>
		<description><![CDATA[One of the great features of PowerShell is how much you can get from a relatively simple one line command. For example. you might want to test if a computer is running a 64-bit operating system. You can find out with a command as simple as this. [crayon-5197fb17a1895/] If you are running PowerShell 3 you [...]]]></description>
				<content:encoded><![CDATA[<p>One of the great features of PowerShell is how much you can get from a relatively simple one line command. For example. you might want to test if a computer is running a 64-bit operating system. You can find out with a command as simple as this.</p>
<p></p><pre class="crayon-plain-tag">PS C:\&gt; (get-wmiobject win32_operatingsystem -comp chi-dc01).OsArchitecture -match "64"
True
PS C:\&gt; (get-wmiobject win32_operatingsystem -comp novo8).OsArchitecture -match "64"
False</pre><p> </p>
<p>If you are running PowerShell 3 you could substitute Get-CimInstance. One thing to be aware of with this particular class is that the OSArchitecture property isn&#8217;t valid on older operating systems like Windows Server 2003. You&#8217;ll get an exception.</p>
<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L29zYXJjaGl0ZWN0dXJlLWZhaWwucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/osarchitecture-fail-1024x298.png" alt="osarchitecture-fail" width="625" height="181" class="aligncenter size-large wp-image-3037" /></a></p>
<p>In this case I modified the WMI query to only return the OSArchitecture property, which doesn&#8217;t exist. Otherwise I would just get false which might not be entirely true. Of course, I always get carried away so before I knew it I had turned this one line command into a function.</p>
<p></p><pre class="crayon-plain-tag">#requires -version 2.0

Function Test-Is64Bit {
[cmdletbinding()]

Param(
[ValidateNotNullorEmpty()]
[string]$Computername=$env:computername,
[Alias("RunAs")]
[System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
)

Try {
  #hash table of parameters to splat
  $wmiParams = @{
    Class = 'win32_operatingsystem'
    Property = 'osarchitecture'
    ComputerName = $computername
    ErrorAction = 'Stop'
  }
  if ($credential) {
    Write-Verbose "Adding credential"
    $wmiParams.Add("Credential",$Credential)
  }
  Write-Verbose "Testing $computername"
  $data = Get-WmiObject @wmiParams
  Write-Verbose $data.OSArchitecture
  $data.OsArchitecture -match "64"

} #try

Catch {
  Switch -wildcard ($error[0].Exception.Message) {
   "The RPC Server*" { 
      Write-Warning "Can't connect to server. Verify name and availability." 
      }
   "Access is denied*" {
      Write-Warning "Access denied. Check your permissions."
      }
   "Invalid query*" {
      Write-Warning "WMI information not available. OS version may Windows 2003 or earlier."
      }
  Default { 
    Write-Error $error[0]
    }
  } #switch
} #catch

Finally {
    Write-Verbose "Finished testing"
} #finally

} #close function</pre><p> </p>
<p>The function takes a computername and optionally a PSCredential. You can use a saved PSCredential object or specify the name and you will be prompted.</p>
<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L1Rlc3QtSXM2NEJpdC0wMS5wbmcjdXRtX3NvdXJjZT1mZWVkJmFtcDt1dG1fbWVkaXVtPWZlZWQmYW1wO3V0bV9jYW1wYWlnbj1mZWVk"><img src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/Test-Is64Bit-01-1024x492.png" alt="Test-Is64Bit-01" width="625" height="300" class="aligncenter size-large wp-image-3038" /></a><br />
The other design element is that if there is an exception caught I have a Switch statement to checks the message and writes a custom warning.<br />
<a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L1Rlc3QtSXM2NEJpdC0wMi5wbmcjdXRtX3NvdXJjZT1mZWVkJmFtcDt1dG1fbWVkaXVtPWZlZWQmYW1wO3V0bV9jYW1wYWlnbj1mZWVk"><img src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/Test-Is64Bit-02-1024x517.png" alt="Test-Is64Bit-02" width="625" height="315" class="aligncenter size-large wp-image-3039" /></a></p>
<p>There&#8217;s no reason you can&#8217;t use the one-liner. But if you want to add a bit more robustness and create a re-usable tool, it doesn&#8217;t take much to turn it into a simple function.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVRlc3QrNjQtQml0K09wZXJhdGluZytTeXN0ZW0raHR0cCUzQSUyRiUyRmpkaGl0c29sdXRpb25zLmNvbSUyRmJsb2clMkYyMDEzJTJGMDUlMkZ0ZXN0LTY0LWJpdC1vcGVyYXRpbmctc3lzdGVtJTJG" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVzdC02NC1iaXQtb3BlcmF0aW5nLXN5c3RlbS8mYW1wO3RpdGxlPVRlc3QrNjQtQml0K09wZXJhdGluZytTeXN0ZW0=" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVzdC02NC1iaXQtb3BlcmF0aW5nLXN5c3RlbS8mYW1wO3RpdGxlPVRlc3QrNjQtQml0K09wZXJhdGluZytTeXN0ZW0=" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVzdC02NC1iaXQtb3BlcmF0aW5nLXN5c3RlbS8mYW1wO3Q9VGVzdCs2NC1CaXQrT3BlcmF0aW5nK1N5c3RlbQ==" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1UZXN0KzY0LUJpdCtPcGVyYXRpbmcrU3lzdGVtJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Rlc3QtNjQtYml0LW9wZXJhdGluZy1zeXN0ZW0v" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9VGVzdCs2NC1CaXQrT3BlcmF0aW5nK1N5c3RlbSZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZXN0LTY0LWJpdC1vcGVyYXRpbmctc3lzdGVtLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErT25lK29mK3RoZStncmVhdCtmZWF0dXJlcytvZitQb3dlclNoZWxsK2lzK2hvdyttdWNoK3lvdStjYW4rZ2V0K2Zyb20rYStyZWxhdGl2ZWx5K3NpbXBsZStvbmUrbGluZStjb21tYW5kLitGb3IrZXhhbXBsZS4reW91K21pZ2h0K3dhbnQrdG8rdGVzdCtpZithLi4u" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9VGVzdCs2NC1CaXQrT3BlcmF0aW5nK1N5c3RlbSZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZXN0LTY0LWJpdC1vcGVyYXRpbmctc3lzdGVtLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErT25lK29mK3RoZStncmVhdCtmZWF0dXJlcytvZitQb3dlclNoZWxsK2lzK2hvdyttdWNoK3lvdStjYW4rZ2V0K2Zyb20rYStyZWxhdGl2ZWx5K3NpbXBsZStvbmUrbGluZStjb21tYW5kLitGb3IrZXhhbXBsZS4reW91K21pZ2h0K3dhbnQrdG8rdGVzdCtpZithLi4u" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Rlc3QtNjQtYml0LW9wZXJhdGluZy1zeXN0ZW0vJmFtcDt0aXRsZT1UZXN0KzY0LUJpdCtPcGVyYXRpbmcrU3lzdGVtJmFtcDtzdW1tYXJ5PU9uZStvZit0aGUrZ3JlYXQrZmVhdHVyZXMrb2YrUG93ZXJTaGVsbCtpcytob3crbXVjaCt5b3UrY2FuK2dldCtmcm9tK2ErcmVsYXRpdmVseStzaW1wbGUrb25lK2xpbmUrY29tbWFuZC4rRm9yK2V4YW1wbGUuK3lvdSttaWdodCt3YW50K3RvK3Rlc3QraWYrYS4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Rlc3QtNjQtYml0LW9wZXJhdGluZy1zeXN0ZW0vJmFtcDt0aXRsZT1UZXN0KzY0LUJpdCtPcGVyYXRpbmcrU3lzdGVtJmFtcDtzdW1tYXJ5PU9uZStvZit0aGUrZ3JlYXQrZmVhdHVyZXMrb2YrUG93ZXJTaGVsbCtpcytob3crbXVjaCt5b3UrY2FuK2dldCtmcm9tK2ErcmVsYXRpdmVseStzaW1wbGUrb25lK2xpbmUrY29tbWFuZC4rRm9yK2V4YW1wbGUuK3lvdSttaWdodCt3YW50K3RvK3Rlc3QraWYrYS4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1UZXN0KzY0LUJpdCtPcGVyYXRpbmcrU3lzdGVtJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Rlc3QtNjQtYml0LW9wZXJhdGluZy1zeXN0ZW0v" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZXN0LTY0LWJpdC1vcGVyYXRpbmctc3lzdGVtLyZhbXA7dGl0bGU9VGVzdCs2NC1CaXQrT3BlcmF0aW5nK1N5c3RlbQ==" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVzdC02NC1iaXQtb3BlcmF0aW5nLXN5c3RlbS8mYW1wO3RpdGxlPVRlc3QrNjQtQml0K09wZXJhdGluZytTeXN0ZW0=" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Rlc3QtNjQtYml0LW9wZXJhdGluZy1zeXN0ZW0vJmFtcDt0aXRsZT1UZXN0KzY0LUJpdCtPcGVyYXRpbmcrU3lzdGVt" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZXN0LTY0LWJpdC1vcGVyYXRpbmctc3lzdGVtLw==" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3036" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/QiwElRGeP4o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/test-64-bit-operating-system/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/test-64-bit-operating-system/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=test-64-bit-operating-system</feedburner:origLink></item>
		<item>
		<title>PowerShell Version Profiles</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/ALDNwjSaWQs/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/powershell-version-profiles/#comments</comments>
		<pubDate>Wed, 15 May 2013 13:06:41 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Profile]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3032</guid>
		<description><![CDATA[One of the best things about PowerShell 3.0, for me anyway, is the ability to run PowerShell 2.0 side by side. I often need to test commands and scripts in both versions not only for my writing projects but also when helping people out. Like many of you I have a PowerShell profile script that [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDExLzEwL3RhbGtidWJibGUucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-thumbnail wp-image-1688" alt="talkbubble" src="http://jdhitsolutions.com/blog/wp-content/uploads/2011/10/talkbubble-150x150.png" width="150" height="150" /></a> One of the best things about PowerShell 3.0, for me anyway, is the ability to run PowerShell 2.0 side by side. I often need to test commands and scripts in both versions not only for my writing projects but also when helping people out. Like many of you I have a PowerShell profile script that configures my console. And because I primarily use PowerShell 3.0 I tend to have a number of version specific commands in my profile. The problem is that when I launch a PowerShell 2.0 session it uses the same profile, resulting in error messages for things it can&#8217;t do. So this is how I handle having a single profile that can be used by two different versions of PowerShell.</p>
<p>Basically, my profile script checks the version first, before doing anything. You can use the $psversiontable variable.</p><pre class="crayon-plain-tag">PS C:\&gt; $PSVersionTable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.18033
BuildVersion                   6.2.9200.16434
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2</pre><p>The PSVersion property is what I&#8217;m looking for. With this information, I can wrap my PowerShell profile script in simple IF statement.</p><pre class="crayon-plain-tag">#requires -version 2.0

&lt;#
Use code like this in your PowerShell profile if it will
be shared between PowerShell 2 and PowerShell 3 sessions
on the same computer
#&gt;

if ($psversiontable.psversion -eq '3.0') {
 Write-Host "You are running PowerShell 3.0" -ForegroundColor Green
 #insert 3.0 specific commands
 $PSDefaultParameterValues.Add("Format-Table:Autosize",$True)
}
else {
  Write-Host "You are running PowerShell 2.0" -ForegroundColor Yellow
  #insert 2.0 specific commands
}

#insert commands that apply to both versions</pre><p>I think the comments in the code sample are pretty clear and there&#8217;s really not much else to add. The Write-Host lines are merely for testing. You don&#8217;t really need them.</p>
<p>Now I can get properly configured PowerShell sessions regardless of version and without errors.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVBvd2VyU2hlbGwrVmVyc2lvbitQcm9maWxlcytodHRwJTNBJTJGJTJGamRoaXRzb2x1dGlvbnMuY29tJTJGYmxvZyUyRjIwMTMlMkYwNSUyRnBvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcyUyRg==" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtWZXJzaW9uK1Byb2ZpbGVz" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtWZXJzaW9uK1Byb2ZpbGVz" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLyZhbXA7dD1Qb3dlclNoZWxsK1ZlcnNpb24rUHJvZmlsZXM=" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1Qb3dlclNoZWxsK1ZlcnNpb24rUHJvZmlsZXMmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLw==" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtWZXJzaW9uK1Byb2ZpbGVzJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcy8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytPbmUrb2YrdGhlK2Jlc3QrdGhpbmdzK2Fib3V0K1Bvd2VyU2hlbGwrMy4wJTJDK2ZvcittZSthbnl3YXklMkMraXMrdGhlK2FiaWxpdHkrdG8rcnVuK1Bvd2VyU2hlbGwrMi4wK3NpZGUrYnkrc2lkZS4rSStvZnRlbituZWVkK3RvK3Rlc3QrY29tbWFuZHMrYW5kK3MuLi4=" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtWZXJzaW9uK1Byb2ZpbGVzJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcy8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytPbmUrb2YrdGhlK2Jlc3QrdGhpbmdzK2Fib3V0K1Bvd2VyU2hlbGwrMy4wJTJDK2ZvcittZSthbnl3YXklMkMraXMrdGhlK2FiaWxpdHkrdG8rcnVuK1Bvd2VyU2hlbGwrMi4wK3NpZGUrYnkrc2lkZS4rSStvZnRlbituZWVkK3RvK3Rlc3QrY29tbWFuZHMrYW5kK3MuLi4=" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrVmVyc2lvbitQcm9maWxlcyZhbXA7c3VtbWFyeT0rT25lK29mK3RoZStiZXN0K3RoaW5ncythYm91dCtQb3dlclNoZWxsKzMuMCUyQytmb3IrbWUrYW55d2F5JTJDK2lzK3RoZSthYmlsaXR5K3RvK3J1bitQb3dlclNoZWxsKzIuMCtzaWRlK2J5K3NpZGUuK0krb2Z0ZW4rbmVlZCt0byt0ZXN0K2NvbW1hbmRzK2FuZCtzLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrVmVyc2lvbitQcm9maWxlcyZhbXA7c3VtbWFyeT0rT25lK29mK3RoZStiZXN0K3RoaW5ncythYm91dCtQb3dlclNoZWxsKzMuMCUyQytmb3IrbWUrYW55d2F5JTJDK2lzK3RoZSthYmlsaXR5K3RvK3J1bitQb3dlclNoZWxsKzIuMCtzaWRlK2J5K3NpZGUuK0krb2Z0ZW4rbmVlZCt0byt0ZXN0K2NvbW1hbmRzK2FuZCtzLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1ZlcnNpb24rUHJvZmlsZXMmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLw==" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXZlcnNpb24tcHJvZmlsZXMvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1ZlcnNpb24rUHJvZmlsZXM=" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC12ZXJzaW9uLXByb2ZpbGVzLyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtWZXJzaW9uK1Byb2ZpbGVz" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtdmVyc2lvbi1wcm9maWxlcy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrVmVyc2lvbitQcm9maWxlcw==" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXZlcnNpb24tcHJvZmlsZXMv" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3032" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/ALDNwjSaWQs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/powershell-version-profiles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/powershell-version-profiles/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-version-profiles</feedburner:origLink></item>
		<item>
		<title>Scrub Up PowerShell Content</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/K6ed8EMmxmU/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/scrub-up-powershell-content/#comments</comments>
		<pubDate>Tue, 14 May 2013 14:39:09 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Filter]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3025</guid>
		<description><![CDATA[It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There&#8217;s nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L3NjcnViYnJ1c2guanBnI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-medium wp-image-3026" alt="scrubbrush" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/scrubbrush-300x214.jpg" width="300" height="214" /></a> It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There&#8217;s nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique to your company. Getting data out of these text files is very easy in PowerShell using Get-Content.</p><pre class="crayon-plain-tag">get-content c:\work\computers.txt</pre><p>The potential problem is that the text file may not be perfectly formatted. Your text file might have blank lines. Or your computername may have a trailing white space. These things can complicate using the text file in a PowerShell pipelined expression. One approach is to filter the content using Where-Object and simply look for the existing of something.</p><pre class="crayon-plain-tag">get-content c:\work\computers.txt | where {$_} | &lt;something else&gt;</pre><p>This works fine in filtering out blank lines. But won&#8217;t fail if you have a line where someone inserted a tab or hit the space bar a few times. So let&#8217;s take this a bit further and use a regular expression to filter out anything that doesn&#8217;t have a non-whitespace character.</p><pre class="crayon-plain-tag">get-content c:\work\computers.txt | where {$_ -match "\w+"} | &lt;something else&gt;</pre><p>This should get rid of any lines that are nothing but tabs or spaces. Of course, there is still the issue of leading or trailing spaces. But we can handle that by using the string object&#8217;s Trim() method.</p>
<p>This is starting to get complicated. So I wrote a filtering function to scrub up content presumably from text files.</p><pre class="crayon-plain-tag">#requires -version 2.0

Filter Scrub {
&lt;#
.Synopsis
Clean input strings
.Description
This command is designed to take string input and scrub the data, filtering
out blank lines and removing leading and trailing spaces. The default behavior
is to write the object to the pipeline, however you can use -PropertyName to
add a property name value. If you use this parameter, the assumption is that
contents of the text file are a single item like a computer name.
.Example
PS C:\&gt; get-content c:\work\computers.txt | scrub | foreach { get-wmiobject win32_operatingsystem -comp $_}
.Example
PS C:\&gt; get-content c:\work\computers.txt | scrub -PropertyName computername | test-connection 
#&gt;

[cmdletbinding()]
Param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[string[]]$InputObject,
[string]$PropertyName
)

  #filter out blank lines
  $InputObject | where {$_ -match "\w+"} | 
  ForEach-Object { 
    #trim off trailing and leading spaces
    $clean = $_.Trim()
    if ($PropertyName) {
        #create a customobject property
        New-Object -TypeName PSObject -Property @{$PropertyName=$clean}
    }
    else {
        #write the clean object to the pipeline
        $clean
    }
    } #foreach 

} #close Scrub</pre><p>We don&#8217;t use the Filter keyword much anymore but it seemed appropriate because that is the only thing Scrub is doing. In fact, I intentionally did not use a traditional verb-noun name. Technically this an advanced function this is just a Process script block. I wrote it with the assumption that you would pipe strings from Get-Content.</p>
<p>Each processed string is filtered to get rid of blanks and spaces. Then each string is trimmed of leading and trailing spaces and finally written to the pipeline. Now I can run a command line this:</p><pre class="crayon-plain-tag">get-content c:\scripts\computers.txt | scrub</pre><p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L3NjcnViZXhhbXBsZTEucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="aligncenter size-medium wp-image-3027" alt="scrubexample1" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/scrubexample1-300x106.png" width="300" height="106" /></a></p>
<p>In my initial versions this solved all of my potential problems with text files. But then I realize I had an opportunity to add one more scrubbing feature. Many cmdlets have parameters that take pipeline input by property name. But strings from text files lack a property name. So I added a parameter to my Scrub filter to add a property name.</p><pre class="crayon-plain-tag">get-content c:\scripts\computers.txt | scrub -PropertyName Computername</pre><p>Now I&#8217;m writing an object to the pipeline and can take advantage of pipeline binding.</p>
<p></p><pre class="crayon-plain-tag">get-content c:\scripts\computers.txt | scrub -PropertyName Computername | test-connection -Count 1</pre><p> </p>
<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L3NjcnViZXhhbXBsZTIucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="aligncenter size-medium wp-image-3028" alt="scrubexample2" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/scrubexample2-300x130.png" width="300" height="130" /></a></p>
<p>I don&#8217;t know about you, but this will come in very handy. I hope you&#8217;ll let me know what you think.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVNjcnViK1VwK1Bvd2VyU2hlbGwrQ29udGVudCtodHRwJTNBJTJGJTJGamRoaXRzb2x1dGlvbnMuY29tJTJGYmxvZyUyRjIwMTMlMkYwNSUyRnNjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudCUyRg==" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50LyZhbXA7dGl0bGU9U2NydWIrVXArUG93ZXJTaGVsbCtDb250ZW50" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50LyZhbXA7dGl0bGU9U2NydWIrVXArUG93ZXJTaGVsbCtDb250ZW50" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50LyZhbXA7dD1TY3J1YitVcCtQb3dlclNoZWxsK0NvbnRlbnQ=" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1TY3J1YitVcCtQb3dlclNoZWxsK0NvbnRlbnQmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50Lw==" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9U2NydWIrVXArUG93ZXJTaGVsbCtDb250ZW50JmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3NjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytJdCtpcytwcm9iYWJseSthK3NhZmUrYmV0K3RvK3NheSt0aGF0K0lUK1Byb3Mrc3RvcmUrYStsb3Qrb2YraW5mb3JtYXRpb24raW4rc2ltcGxlK3RleHQrZmlsZXMuK1RoZXJlJTI3cytub3RoaW5nK3dpdGgrdGhpcy4rTm90ZXBhZCtpcyt1YmlxdWl0b3VzK2FuLi4u" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9U2NydWIrVXArUG93ZXJTaGVsbCtDb250ZW50JmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3NjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytJdCtpcytwcm9iYWJseSthK3NhZmUrYmV0K3RvK3NheSt0aGF0K0lUK1Byb3Mrc3RvcmUrYStsb3Qrb2YraW5mb3JtYXRpb24raW4rc2ltcGxlK3RleHQrZmlsZXMuK1RoZXJlJTI3cytub3RoaW5nK3dpdGgrdGhpcy4rTm90ZXBhZCtpcyt1YmlxdWl0b3VzK2FuLi4u" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3NjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudC8mYW1wO3RpdGxlPVNjcnViK1VwK1Bvd2VyU2hlbGwrQ29udGVudCZhbXA7c3VtbWFyeT0rSXQraXMrcHJvYmFibHkrYStzYWZlK2JldCt0bytzYXkrdGhhdCtJVCtQcm9zK3N0b3JlK2ErbG90K29mK2luZm9ybWF0aW9uK2luK3NpbXBsZSt0ZXh0K2ZpbGVzLitUaGVyZSUyN3Mrbm90aGluZyt3aXRoK3RoaXMuK05vdGVwYWQraXMrdWJpcXVpdG91cythbi4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3NjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudC8mYW1wO3RpdGxlPVNjcnViK1VwK1Bvd2VyU2hlbGwrQ29udGVudCZhbXA7c3VtbWFyeT0rSXQraXMrcHJvYmFibHkrYStzYWZlK2JldCt0bytzYXkrdGhhdCtJVCtQcm9zK3N0b3JlK2ErbG90K29mK2luZm9ybWF0aW9uK2luK3NpbXBsZSt0ZXh0K2ZpbGVzLitUaGVyZSUyN3Mrbm90aGluZyt3aXRoK3RoaXMuK05vdGVwYWQraXMrdWJpcXVpdG91cythbi4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1TY3J1YitVcCtQb3dlclNoZWxsK0NvbnRlbnQmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50Lw==" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9zY3J1Yi11cC1wb3dlcnNoZWxsLWNvbnRlbnQvJmFtcDt0aXRsZT1TY3J1YitVcCtQb3dlclNoZWxsK0NvbnRlbnQ=" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvc2NydWItdXAtcG93ZXJzaGVsbC1jb250ZW50LyZhbXA7dGl0bGU9U2NydWIrVXArUG93ZXJTaGVsbCtDb250ZW50" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3NjcnViLXVwLXBvd2Vyc2hlbGwtY29udGVudC8mYW1wO3RpdGxlPVNjcnViK1VwK1Bvd2VyU2hlbGwrQ29udGVudA==" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9zY3J1Yi11cC1wb3dlcnNoZWxsLWNvbnRlbnQv" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3025" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/K6ed8EMmxmU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/scrub-up-powershell-content/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/scrub-up-powershell-content/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=scrub-up-powershell-content</feedburner:origLink></item>
		<item>
		<title>PowerShell Scripting Games 2013 Impressions</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/qdPXLUKMTGc/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/powershell-scripting-games-2013-impressions/#comments</comments>
		<pubDate>Mon, 13 May 2013 13:49:16 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ScriptingGames]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3019</guid>
		<description><![CDATA[Now that the PowerShell Scripting Games for 2013 are well underway, I thought I&#8217;d share my thoughts and impressions on what I&#8217;ve seen. I&#8217;m very impressed with the number of entries and generally the quality is pretty good. But as a judge I see repeated items that bear comment. These comments are in no particular [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft" alt="" src="http://scriptinggames.org/games-logo.png" width="400" height="150" />Now that the <a title=\"Visit the ScriptingGames\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NjcmlwdGluZ2dhbWVzLm9yZy9ob21lLnBocA==" target=\"_blank\">PowerShell Scripting Games </a>for 2013 are well underway, I thought I&#8217;d share my thoughts and impressions on what I&#8217;ve seen. I&#8217;m very impressed with the number of entries and generally the quality is pretty good. But as a judge I see repeated items that bear comment. These comments are in no particular order of importance and in some cases are really a matter of personal preference.</p>
<p>If you are going to use Write-Host (and want to save puppies) to display informational or progress messages, please use one of the color parameters so that your message can be differentiated from your object output. Ideally for advanced events you should be using Write-Progress. Not sure we&#8217;ve had events that call for Write-Progress but keep it in mind.</p>
<p>I generally dislike entries that are clearly overwrought and over-thought. Sometimes the problem can be solved simply. Don&#8217;t feel you have to use every trick in the PowerShell play book in order to score points. I&#8217;m a big proponent of the right tool for the job. On a related note, if you can solve the challenge with a PowerShell one-liner, don&#8217;t feel you need to write it as a long single line command. Take advantage of PowerShell parsing. This is very hard to read:</p><pre class="crayon-plain-tag">Get-WmiObject win32_operatingsystem -comp $computers | select PSComputername,@{Name="TotalMemoryMB";Expression={[int]($_.TotalVisibleMemorySize/1KB)}},@{Name="FreeMemoryMB";Expression={[math]::Round($_.FreePhysicalmemory/1KB,2)}},@{Name="PercentMemoryFree";Expression={[math]::Round(($_.freephysicalmemory/$_.totalvisibleMemorySize)*100,2)}} | Sort PSComputername | Export-CSV -Path c:\work\osreport.csv -Encoding ASCII -NoTypeInformation</pre><p>I&#8217;d much rather see a one-liner formatted like this:</p><pre class="crayon-plain-tag">Get-WmiObject win32_operatingsystem -comp $computers | 
select PSComputername,
@{Name="TotalMemoryMB";Expression={[int]($_.TotalVisibleMemorySize/1KB)}},
@{Name="FreeMemoryMB";Expression={[math]::Round($_.FreePhysicalmemory/1KB,2)}},
@{Name="PercentMemoryFree";
Expression={[math]::Round(($_.freephysicalmemory/$_.totalvisibleMemorySize)*100,2)}} |
Sort PSComputername | 
Export-CSV -Path c:\work\osreport.csv -Encoding ASCII -NoTypeInformation</pre><p>In full scripts, I&#8217;d like to see more use of #Requires -version X so that I can tell what features you might be using. Related to that, in advanced scripts if you are using a parameter attribute like Mandatory or ValueFromPipeline, v3 scripts should use them like this:</p><pre class="crayon-plain-tag">[Parameter(Position=0,ValueFromPipeline,Mandatory)]</pre><p>You don&#8217;t have to explicitly state that Mandatory is equal to True. Although in v2 you would need to do this:</p><pre class="crayon-plain-tag">[Parameter(Position=0,ValueFromPipeline=$True,Mandatory=$True)]</pre><p>Which brings me to another minor irk, an object that has a boolean value doesn&#8217;t need a comparison operator. The whole point of something like an IF statement is to evaluate if the expression in the parentheses is true or not. If the object is already a boolean, there&#8217;s no need.</p><pre class="crayon-plain-tag">$found = $True

#bad form
if ($found -eq $True) {
 #deleting computer from active directory
 #...
}

#better form
if ($found) {
 #deleting computer from active directory
 #...
}</pre><p>I&#8217;m also not a big fan of creating custom objects with lots of Add-Member commands. I think this makes the code harder to read and doesn&#8217;t really buy you much. I think using a hashtable with New-Object is much easier to read and just as effective. Plus in v3 we can now have ordered hashtables and even use [pscustomobject].</p><pre class="crayon-plain-tag">$os = Get-CimInstance -class win32_operatingsystem -ComputerName $computer
$computersystem = Get-CimInstance -ClassName win32_computersystem -ComputerName $computer
$is64Bit = If ($os.OSArchitecture -match "64") { $True } Else {$False}

$Inventory = [ordered]@{
Computername = $os.PSComputername
OperatingSystem = $os.Caption
Installed = $os.InstallDate
Model = $computersystem.Model
Mfg = $computersystem.Manufacturer
Is64Bit = $Is64Bit
}

[pscustomobject]$Inventory</pre><p>Finally, be very careful of including formatting commands in your entries, unless the event specifically calls for it. This is especially true if you are writing a function. When you include formatting directives at the end of the function, it can&#8217;t be used anywhere else in a PowerShell expression.</p>
<p>Don&#8217;t get me wrong, there is a lot of good PowerShell which I&#8217;m happy to see:</p>
<ul>
<li>Using Join-Path to build paths</li>
<li>Using Test-Path to validate</li>
<li>Plenty of internal comments</li>
<li>Using Test-Connection to verify computers are online</li>
<li>Meaningful variable names</li>
</ul>
<p>So keep up the good work and on to the next event!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVBvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzKzIwMTMrSW1wcmVzc2lvbnMraHR0cCUzQSUyRiUyRmpkaGl0c29sdXRpb25zLmNvbSUyRmJsb2clMkYyMDEzJTJGMDUlMkZwb3dlcnNoZWxsLXNjcmlwdGluZy1nYW1lcy0yMDEzLWltcHJlc3Npb25zJTJG" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1zY3JpcHRpbmctZ2FtZXMtMjAxMy1pbXByZXNzaW9ucy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzKzIwMTMrSW1wcmVzc2lvbnM=" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1zY3JpcHRpbmctZ2FtZXMtMjAxMy1pbXByZXNzaW9ucy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzKzIwMTMrSW1wcmVzc2lvbnM=" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1zY3JpcHRpbmctZ2FtZXMtMjAxMy1pbXByZXNzaW9ucy8mYW1wO3Q9UG93ZXJTaGVsbCtTY3JpcHRpbmcrR2FtZXMrMjAxMytJbXByZXNzaW9ucw==" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1Qb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcysyMDEzK0ltcHJlc3Npb25zJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtc2NyaXB0aW5nLWdhbWVzLTIwMTMtaW1wcmVzc2lvbnMv" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtTY3JpcHRpbmcrR2FtZXMrMjAxMytJbXByZXNzaW9ucyZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXNjcmlwdGluZy1nYW1lcy0yMDEzLWltcHJlc3Npb25zLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErTm93K3RoYXQrdGhlK1Bvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzK2ZvcisyMDEzK2FyZSt3ZWxsK3VuZGVyd2F5JTJDK0krdGhvdWdodCtJJTI3ZCtzaGFyZStteSt0aG91Z2h0cythbmQraW1wcmVzc2lvbnMrb24rd2hhdCtJJTI3dmUrc2Vlbi4rSSUyN20rdmVyeStpbXAuLi4=" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtTY3JpcHRpbmcrR2FtZXMrMjAxMytJbXByZXNzaW9ucyZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXNjcmlwdGluZy1nYW1lcy0yMDEzLWltcHJlc3Npb25zLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErTm93K3RoYXQrdGhlK1Bvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzK2ZvcisyMDEzK2FyZSt3ZWxsK3VuZGVyd2F5JTJDK0krdGhvdWdodCtJJTI3ZCtzaGFyZStteSt0aG91Z2h0cythbmQraW1wcmVzc2lvbnMrb24rd2hhdCtJJTI3dmUrc2Vlbi4rSSUyN20rdmVyeStpbXAuLi4=" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtc2NyaXB0aW5nLWdhbWVzLTIwMTMtaW1wcmVzc2lvbnMvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcysyMDEzK0ltcHJlc3Npb25zJmFtcDtzdW1tYXJ5PU5vdyt0aGF0K3RoZStQb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcytmb3IrMjAxMythcmUrd2VsbCt1bmRlcndheSUyQytJK3Rob3VnaHQrSSUyN2Qrc2hhcmUrbXkrdGhvdWdodHMrYW5kK2ltcHJlc3Npb25zK29uK3doYXQrSSUyN3ZlK3NlZW4uK0klMjdtK3ZlcnkraW1wLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtc2NyaXB0aW5nLWdhbWVzLTIwMTMtaW1wcmVzc2lvbnMvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcysyMDEzK0ltcHJlc3Npb25zJmFtcDtzdW1tYXJ5PU5vdyt0aGF0K3RoZStQb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcytmb3IrMjAxMythcmUrd2VsbCt1bmRlcndheSUyQytJK3Rob3VnaHQrSSUyN2Qrc2hhcmUrbXkrdGhvdWdodHMrYW5kK2ltcHJlc3Npb25zK29uK3doYXQrSSUyN3ZlK3NlZW4uK0klMjdtK3ZlcnkraW1wLi4uJmFtcDtzb3VyY2U9VGhlIExvbmVseSBBZG1pbmlzdHJhdG9y" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcysyMDEzK0ltcHJlc3Npb25zJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtc2NyaXB0aW5nLWdhbWVzLTIwMTMtaW1wcmVzc2lvbnMv" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXNjcmlwdGluZy1nYW1lcy0yMDEzLWltcHJlc3Npb25zLyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtTY3JpcHRpbmcrR2FtZXMrMjAxMytJbXByZXNzaW9ucw==" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1zY3JpcHRpbmctZ2FtZXMtMjAxMy1pbXByZXNzaW9ucy8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrU2NyaXB0aW5nK0dhbWVzKzIwMTMrSW1wcmVzc2lvbnM=" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtc2NyaXB0aW5nLWdhbWVzLTIwMTMtaW1wcmVzc2lvbnMvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1NjcmlwdGluZytHYW1lcysyMDEzK0ltcHJlc3Npb25z" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLXNjcmlwdGluZy1nYW1lcy0yMDEzLWltcHJlc3Npb25zLw==" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3019" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/qdPXLUKMTGc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/powershell-scripting-games-2013-impressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/powershell-scripting-games-2013-impressions/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-scripting-games-2013-impressions</feedburner:origLink></item>
		<item>
		<title>Getting Top Level Folder Report in PowerShell</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/X3z6gV5Jbmg/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/getting-top-level-folder-report-in-powershell/#comments</comments>
		<pubDate>Thu, 09 May 2013 16:34:39 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Powershell 3.0]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Get-ChildItem]]></category>
		<category><![CDATA[Measure-Object]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3014</guid>
		<description><![CDATA[One of the sessions I presented recently at TechDays San Francisco was on file share management with PowerShell. One of the scripts I demonstrated was for a function to get information for top level folders. This is the type of thing that could be handy to run say against the root of your shared users [...]]]></description>
				<content:encoded><![CDATA[<p>One of the sessions I presented recently at TechDays San Francisco was on file share management with PowerShell. One of the scripts I demonstrated was for a function to get information for top level folders. This is the type of thing that could be handy to run say against the root of your shared users folder. Or the root of a group share where each subfolder is a share that belongs to a different group. My function takes advantage of a new feature for Get-ChildItem that makes it much easier to retrieve only file or directories. Here&#8217;s my Get-FolderSize function.</p><pre class="crayon-plain-tag">#requires -version 3.0

Function Get-FolderSize {

&lt;#
.Synopsis
Get a top level folder size report
.Description
This command will analyze the top level folders in a given root. It will write
a custom object to the pipeline that shows the number of files in each folder,
the total size in bytes and folder attributes. The output will also include 
files in the root of the specified path.

Sample output:
Name       : DesktopTileResources
Fullname   : C:\windows\DesktopTileResources
Size       : 21094
Count      : 17
Attributes : ReadOnly, Directory

Use the -Force parameter to include hidden directories.
.Example
PS C:\&gt; get-foldersize c:\work | format-table -auto

Path               Name             Size Count Attributes
----               ----             ---- ----- ----------
C:\work            work        252083656   223  Directory
C:\work\atomic     atomic         622445     6  Directory
C:\work\fooby      fooby              18     1  Directory
C:\work\images     images        1470091   118  Directory
C:\work\resources  resources     8542561   143  Directory
C:\work\shell      shell          225161     4  Directory
C:\work\test       test         17198758     4  Directory
C:\work\Test Rig 2 Test Rig 2    4194304     1  Directory
C:\work\test2      test2              40     2  Directory
C:\work\Ubuntu12   Ubuntu12   7656701952     2  Directory
C:\work\widgets    widgets        162703    49  Directory

.Example
PS C:\&gt; get-foldersize c:\users\jeff\ -force | out-gridview -title Jeff
.Notes
Last Updated: May 8, 2013
Version     : 0.9

  ****************************************************************
  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *
  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *
  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *
  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *
  ****************************************************************
.Link
http://jdhitsolutions.com/blog/2013/05/getting-top-level-folder-report-in-powershell
.Inputs
None
.Outputs
Custom object
#&gt;

[cmdletbinding()]
Param(
[Parameter(Position=0)]
[ValidateScript({Test-Path $_})]
[string]$Path=".",
[switch]$Force
)

Write-Verbose "Starting $($myinvocation.MyCommand)"
Write-Verbose "Analyzing $path"

#define a hashtable of parameters to splat to Get-ChildItem
$dirParams = @{
Path = $Path
ErrorAction = "Stop"
ErrorVariable = "myErr"
Directory = $True
}

if ($hidden) {
    $dirParams.Add("Force",$True)
}
$activity = $myinvocation.MyCommand

Write-Progress -Activity $activity -Status "Getting top level folders" -CurrentOperation $Path

$folders = Get-ChildItem @dirParams

#process each folder
$folders | 
foreach -begin {
     Write-Verbose $Path
     #initialize some total counters
     $totalFiles = 0
     $totalSize = 0
     #initialize a counter for progress bar
     $i=0

     Try {     
        #measure files in $Path root
        Write-Progress -Activity $activity -Status $Path -CurrentOperation "Measuring root folder" -PercentComplete 0
        #modify dirParams hashtable
        $dirParams.Remove("Directory")
        $dirParams.Add("File",$True)
        $stats = Get-ChildItem @dirParams | Measure-Object -Property length -sum
     }
     Catch {
        $msg = "Error: $($myErr[0].ErrorRecord.CategoryInfo.Category) $($myErr[0].ErrorRecord.CategoryInfo.TargetName)"
        Write-Warning $msg
     }
     #increment the grand totals
     $totalFiles+= $stats.Count
     $totalSize+= $stats.sum

     if ($stats.count -eq 0) {
        #set size to 0 if the top level folder is empty
        $size = 0
     }
     else {
        $size=$stats.sum
     }

     $root = Get-Item -Path $path
     #define properties for the custom object
     $hash = [ordered]@{
         Path = $root.FullName
         Name = $root.Name
         Size = $size
         Count = $stats.count
         Attributes = (Get-Item $path).Attributes
         }
     #write the object for the folder root
     New-Object -TypeName PSobject -Property $hash

    } -process { 
     Try {
        Write-Verbose $_.fullname
        $i++
        [int]$percomplete = ($i/$folders.count)*100
        Write-Progress -Activity $activity -Status $_.fullname -CurrentOperation "Measuring folder" -PercentComplete $percomplete

        #get directory information for top level folders
        $dirParams.Path = $_.Fullname
        $stats = Get-ChildItem @dirParams -Recurse | Measure-Object -Property length -sum
     }
     Catch {
        $msg = "Error: $($myErr[0].ErrorRecord.CategoryInfo.Category) $($myErr[0].ErrorRecord.CategoryInfo.TargetName)"
        Write-Warning $msg
     }
     #increment the grand totals
     $totalFiles+= $stats.Count
     $totalSize+= $stats.sum

     if ($stats.count -eq 0) {
        #set size to 0 if the top level folder is empty
       $size = 0
     }
     else {
        $size=$stats.sum
     }
     #define properties for the custom object
     $hash = [ordered]@{
         Path = $_.FullName
         Name = $_.Name
         Size = $size
         Count = $stats.count
         Attributes = $_.Attributes
        }
     #write the object for each top level folder
     New-Object -TypeName PSobject -Property $hash
 } -end {
    Write-Progress -Activity $activity -Status "Finished" -Completed
    Write-Verbose "Total number of files for $path = $totalfiles"
    Write-Verbose "Total file size in bytes for $path = $totalsize"
 }

 Write-Verbose "Ending $($myinvocation.MyCommand)"
 } #end Get-FolderSize</pre><p>The function defaults to the local path and gets a collection of all of the top level folders, that is, those found directly in the root. The function then takes the collection of folders and pipes them to ForEach-Object. Most of the time we only use the Process scriptblock with ForEach-Object, but I want to take advantage of the Begin and End blocks as well. In the Begin scriptblock I measure all of the files in the root of the parent path and create a custom object that shows the number of files and total size in bytes. I&#8217;m going to get this same information for each child folder as well.</p>
<p>The process scriptblock does just that for each top level folder. This version of my function uses Write-Progress to display progress and in the End script block I have code to complete the progress bar, although It works just fine without it.</p>
<p>Other techniques I&#8217;d like to point out are the use of splatting and error handling. You&#8217;ll notice that I&#8217;m using the common -ErrorVariable parameter. After exploring the different types of exceptions I decided I could easily display any errors and the paths In the Catch block. I&#8217;m using Write-Warning, but this could just as easily be written to a text file.</p>
<p>The function writes an object like this for every folder.</p><pre class="crayon-plain-tag">Path       : C:\windows\Inf
Name       : Inf
Size       : 81926300
Count      : 1265
Attributes : Directory</pre><p>Here&#8217;s an example of complete output:</p>
<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L2ZvbGRlcnNpemUucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="aligncenter size-large wp-image-3016" alt="foldersize" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/foldersize-1024x589.png" width="625" height="359" /></a>Because I&#8217;ve written objects to the pipeline, I could pipe this to Out-Gridview, export to a CSV file or create an HTML report.</p>
<p>This is just a taste of what you can accomplish with some basic PowerShell commands.</p>
<p>&nbsp;</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PUdldHRpbmcrVG9wK0xldmVsK0ZvbGRlcitSZXBvcnQraW4rUG93ZXJTaGVsbCtodHRwJTNBJTJGJTJGamRoaXRzb2x1dGlvbnMuY29tJTJGYmxvZyUyRjIwMTMlMkYwNSUyRmdldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbCUyRg==" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLyZhbXA7dGl0bGU9R2V0dGluZytUb3ArTGV2ZWwrRm9sZGVyK1JlcG9ydCtpbitQb3dlclNoZWxs" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLyZhbXA7dGl0bGU9R2V0dGluZytUb3ArTGV2ZWwrRm9sZGVyK1JlcG9ydCtpbitQb3dlclNoZWxs" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLyZhbXA7dD1HZXR0aW5nK1RvcCtMZXZlbCtGb2xkZXIrUmVwb3J0K2luK1Bvd2VyU2hlbGw=" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1HZXR0aW5nK1RvcCtMZXZlbCtGb2xkZXIrUmVwb3J0K2luK1Bvd2VyU2hlbGwmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLw==" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9R2V0dGluZytUb3ArTGV2ZWwrRm9sZGVyK1JlcG9ydCtpbitQb3dlclNoZWxsJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2dldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBK09uZStvZit0aGUrc2Vzc2lvbnMrSStwcmVzZW50ZWQrcmVjZW50bHkrYXQrVGVjaERheXMrU2FuK0ZyYW5jaXNjbyt3YXMrb24rZmlsZStzaGFyZSttYW5hZ2VtZW50K3dpdGgrUG93ZXJTaGVsbC4rT25lK29mK3RoZStzY3JpcHRzK0krZGVtb25zdHJhdGVkKy4uLg==" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9R2V0dGluZytUb3ArTGV2ZWwrRm9sZGVyK1JlcG9ydCtpbitQb3dlclNoZWxsJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2dldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBK09uZStvZit0aGUrc2Vzc2lvbnMrSStwcmVzZW50ZWQrcmVjZW50bHkrYXQrVGVjaERheXMrU2FuK0ZyYW5jaXNjbyt3YXMrb24rZmlsZStzaGFyZSttYW5hZ2VtZW50K3dpdGgrUG93ZXJTaGVsbC4rT25lK29mK3RoZStzY3JpcHRzK0krZGVtb25zdHJhdGVkKy4uLg==" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2dldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbC8mYW1wO3RpdGxlPUdldHRpbmcrVG9wK0xldmVsK0ZvbGRlcitSZXBvcnQraW4rUG93ZXJTaGVsbCZhbXA7c3VtbWFyeT1PbmUrb2YrdGhlK3Nlc3Npb25zK0krcHJlc2VudGVkK3JlY2VudGx5K2F0K1RlY2hEYXlzK1NhbitGcmFuY2lzY28rd2FzK29uK2ZpbGUrc2hhcmUrbWFuYWdlbWVudCt3aXRoK1Bvd2VyU2hlbGwuK09uZStvZit0aGUrc2NyaXB0cytJK2RlbW9uc3RyYXRlZCsuLi4mYW1wO3NvdXJjZT1UaGUgTG9uZWx5IEFkbWluaXN0cmF0b3I=" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2dldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbC8mYW1wO3RpdGxlPUdldHRpbmcrVG9wK0xldmVsK0ZvbGRlcitSZXBvcnQraW4rUG93ZXJTaGVsbCZhbXA7c3VtbWFyeT1PbmUrb2YrdGhlK3Nlc3Npb25zK0krcHJlc2VudGVkK3JlY2VudGx5K2F0K1RlY2hEYXlzK1NhbitGcmFuY2lzY28rd2FzK29uK2ZpbGUrc2hhcmUrbWFuYWdlbWVudCt3aXRoK1Bvd2VyU2hlbGwuK09uZStvZit0aGUrc2NyaXB0cytJK2RlbW9uc3RyYXRlZCsuLi4mYW1wO3NvdXJjZT1UaGUgTG9uZWx5IEFkbWluaXN0cmF0b3I=" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1HZXR0aW5nK1RvcCtMZXZlbCtGb2xkZXIrUmVwb3J0K2luK1Bvd2VyU2hlbGwmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLw==" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9nZXR0aW5nLXRvcC1sZXZlbC1mb2xkZXItcmVwb3J0LWluLXBvd2Vyc2hlbGwvJmFtcDt0aXRsZT1HZXR0aW5nK1RvcCtMZXZlbCtGb2xkZXIrUmVwb3J0K2luK1Bvd2VyU2hlbGw=" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvZ2V0dGluZy10b3AtbGV2ZWwtZm9sZGVyLXJlcG9ydC1pbi1wb3dlcnNoZWxsLyZhbXA7dGl0bGU9R2V0dGluZytUb3ArTGV2ZWwrRm9sZGVyK1JlcG9ydCtpbitQb3dlclNoZWxs" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L2dldHRpbmctdG9wLWxldmVsLWZvbGRlci1yZXBvcnQtaW4tcG93ZXJzaGVsbC8mYW1wO3RpdGxlPUdldHRpbmcrVG9wK0xldmVsK0ZvbGRlcitSZXBvcnQraW4rUG93ZXJTaGVsbA==" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9nZXR0aW5nLXRvcC1sZXZlbC1mb2xkZXItcmVwb3J0LWluLXBvd2Vyc2hlbGwv" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3014" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/X3z6gV5Jbmg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/getting-top-level-folder-report-in-powershell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/getting-top-level-folder-report-in-powershell/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-top-level-folder-report-in-powershell</feedburner:origLink></item>
		<item>
		<title>PowerShell Messagebox</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/L7pt9Y3lDTk/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/powershell-messagebox/#comments</comments>
		<pubDate>Wed, 08 May 2013 12:27:01 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[MessageBox]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3004</guid>
		<description><![CDATA[Recently I posted an article explaining how to create a popup box in PowerShell using the Wscript.Shell COM object from our VBScript days. That was something I presented at the PowerShell Summit. Another option is a MessageBox, again like we used to use in VBScript. This works very much like the popup except the user [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L21lc3NhZ2Vib3gucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-medium wp-image-3005" alt="messagebox" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/messagebox-300x147.png" width="300" height="147" /></a>Recently I posted an article explaining <a title=\"read the previous article\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDQvcG93ZXJzaGVsbC1wb3B1cC8jdXRtX3NvdXJjZT1mZWVkJmFtcDt1dG1fbWVkaXVtPWZlZWQmYW1wO3V0bV9jYW1wYWlnbj1mZWVk" target=\"_blank\">how to create a popup box in PowerShell</a> using the Wscript.Shell COM object from our VBScript days. That was something I presented at the PowerShell Summit. Another option is a MessageBox, again like we used to use in VBScript. This works very much like the popup except the user has to click a button to dismiss the box. I can&#8217;t think of a compelling reason why you would choose one technique over the other if you need the user to click something. But I&#8217;ll let you make that call. Here&#8217;s the function, New-Messagebox.</p><pre class="crayon-plain-tag">#requires -version 2.0

Function New-Messagebox {

&lt;#
.Synopsis
Display a VisualBasic style message box.
.Description
This function will display a graphical messagebox, like the one from VisualBasic
and VBScript. You must specify a message. The default button is OKOnly and the 
default icon is for Information. If you want to use the value from a button click
in a PowerShell expression, use the -Passthru parameter.

The message box will remain displayed until the user clicks a button. The box may 
also not appear on top, but if you have audio enabled you should hear the Windows 
exclamation sound.
.Parameter Message
The text to display. Keep it short.
.Parameter Button
The button set to display. The default is OKOnly. Possible values are:
    OkOnly
    OkCancel
    AbortRetryIgnore
    YesNoCancel
    YesNo
    RetryCancel
.Parameter Icon
The icon to display. The default is Information. Possible values are:
    Critical
    Question
    Exclamation
    Information
.Parameter Title
The message box title. The default is no title. The title should be less than 
24 characters long, otherwise it will be truncated.
.Parameter NoPassthru
Use this parameter if you DO NOT want the button value to be passed to the pipeline.
.Example
PS C:\&gt; New-Messagebox "Time to go home!"
Display a message box with no title and the OK button.
.Example
PS C:\&gt; $rc=New-Messagebox -message "Do you know what you're doing?" -icon exclamation -button "YesNoCancel" -title "Hey $env:username!!" 
Switch ($rc) {
 "Yes" {"I hope your resume is up to date."}
 "No" {"Wise move."}
 "Cancel" {"When in doubt, punt."}
 Default {"nothing returned"}
}
.Example
PS C:\&gt; New-MessageBox -message "Are you the walrus?" -icon question -title "Hey, Jude" -button YesNo
.Inputs
None
.Outputs
[system.string]
#&gt;

[cmdletbinding()]

Param (
[Parameter(Position=0,Mandatory,HelpMessage="Specify a display message")]
[ValidateNotNullorEmpty()]
[string]$Message,
[ValidateSet("OkOnly","OkCancel","AbortRetryIgnore","YesNoCancel","YesNo","RetryCancel")]
[string]$Button="OkOnly",
[ValidateSet("Critical", "Question", "Exclamation", "Information")]
[string]$Icon="Information",
[string]$Title,
[switch]$NoPassthru
)

#load the necessary assembly
Try { 
    Add-Type -AssemblyName "Microsoft.VisualBasic" -ErrorAction Stop     
    #create the message box using the parameter values
    $returnValue = [microsoft.visualbasic.interaction]::Msgbox($message,"$button,$icon",$title)
}
Catch {
    Write-Warning "Failed to add Microsoft.VisualBasic assembly or create the messagebox."
    Write-Warning $error[0].Exception.Message
}
#do not write return value if -NoPassthru is called
if (-Not $NoPassthru) {
    Write-Output $returnValue
}

} #end function</pre><p>Most of the function is a wrapper around this line:</p><pre class="crayon-plain-tag">$returnValue = [microsoft.visualbasic.interaction]::Msgbox($message,"$button,$icon",$title)</pre><p>Like the popup function, I wanted to make it easier to create a messagebox without having to remember the names for buttons and icons so I use validation sets with my parameters. This makes it much easier to create a command like this in your script:</p><pre class="crayon-plain-tag">New-Messagebox -Message "Do you want to delete the files?" -Button YesNoCancel -Icon Question -Title "Are you sure?"</pre><p>In the version I presented at the PowerShell Summit, the function did not write anything to the pipeline unless you used -Passthru. After thinking about it more, I realized the whole reason you are likely to use a MessageBox is to capture an interaction so I flipped the parameter and now it is -NoPassthru. Now, when the user clicks a button, the text value of that button is automatically written to the pipeline. If you include -NoPassthru you&#8217;ll get nothing. Here&#8217;s an example:</p><pre class="crayon-plain-tag">$ask = New-Messagebox -Message "Do you want to delete all objects in Active Directory?" -Button YesNo -Icon Exclamation -Title "What are you thinking?"
if ($ask -eq "yes") {
 Write-Host "Updating resume..." -ForegroundColor Red
 #evil code
}
else {
 Write-Host "Sanity restored" -ForegroundColor Green
}</pre><p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L21lc3NhZ2Vib3gyLnBuZyN1dG1fc291cmNlPWZlZWQmYW1wO3V0bV9tZWRpdW09ZmVlZCZhbXA7dXRtX2NhbXBhaWduPWZlZWQ="><img class="aligncenter size-full wp-image-3006" alt="messagebox2" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/messagebox2.png" width="396" height="172" /></a></p>
<p>Because the messagebox writes text to the pipeline, it is a little easier to use than the Popup technique where you have to decode an integer value. In any event, you now have some options.</p>
<p>If you find this useful, I hope you&#8217;ll let me know.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVBvd2VyU2hlbGwrTWVzc2FnZWJveCtodHRwJTNBJTJGJTJGamRoaXRzb2x1dGlvbnMuY29tJTJGYmxvZyUyRjIwMTMlMkYwNSUyRnBvd2Vyc2hlbGwtbWVzc2FnZWJveCUyRg==" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94LyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtNZXNzYWdlYm94" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94LyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtNZXNzYWdlYm94" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94LyZhbXA7dD1Qb3dlclNoZWxsK01lc3NhZ2Vib3g=" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1Qb3dlclNoZWxsK01lc3NhZ2Vib3gmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94Lw==" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtNZXNzYWdlYm94JmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtbWVzc2FnZWJveC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBK1JlY2VudGx5K0krcG9zdGVkK2FuK2FydGljbGUrZXhwbGFpbmluZytob3crdG8rY3JlYXRlK2ErcG9wdXArYm94K2luK1Bvd2VyU2hlbGwrdXNpbmcrdGhlK1dzY3JpcHQuU2hlbGwrQ09NK29iamVjdCtmcm9tK291citWQlNjcmlwdCtkYXlzLitUaGF0K3dhcy4uLg==" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtNZXNzYWdlYm94JmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtbWVzc2FnZWJveC8lMEQlMEElMEQlMEEtLS0tJTBEJTBBK1JlY2VudGx5K0krcG9zdGVkK2FuK2FydGljbGUrZXhwbGFpbmluZytob3crdG8rY3JlYXRlK2ErcG9wdXArYm94K2luK1Bvd2VyU2hlbGwrdXNpbmcrdGhlK1dzY3JpcHQuU2hlbGwrQ09NK29iamVjdCtmcm9tK291citWQlNjcmlwdCtkYXlzLitUaGF0K3dhcy4uLg==" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtbWVzc2FnZWJveC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrTWVzc2FnZWJveCZhbXA7c3VtbWFyeT1SZWNlbnRseStJK3Bvc3RlZCthbithcnRpY2xlK2V4cGxhaW5pbmcraG93K3RvK2NyZWF0ZSthK3BvcHVwK2JveCtpbitQb3dlclNoZWxsK3VzaW5nK3RoZStXc2NyaXB0LlNoZWxsK0NPTStvYmplY3QrZnJvbStvdXIrVkJTY3JpcHQrZGF5cy4rVGhhdCt3YXMuLi4mYW1wO3NvdXJjZT1UaGUgTG9uZWx5IEFkbWluaXN0cmF0b3I=" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtbWVzc2FnZWJveC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrTWVzc2FnZWJveCZhbXA7c3VtbWFyeT1SZWNlbnRseStJK3Bvc3RlZCthbithcnRpY2xlK2V4cGxhaW5pbmcraG93K3RvK2NyZWF0ZSthK3BvcHVwK2JveCtpbitQb3dlclNoZWxsK3VzaW5nK3RoZStXc2NyaXB0LlNoZWxsK0NPTStvYmplY3QrZnJvbStvdXIrVkJTY3JpcHQrZGF5cy4rVGhhdCt3YXMuLi4mYW1wO3NvdXJjZT1UaGUgTG9uZWx5IEFkbWluaXN0cmF0b3I=" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1Qb3dlclNoZWxsK01lc3NhZ2Vib3gmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94Lw==" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLW1lc3NhZ2Vib3gvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK01lc3NhZ2Vib3g=" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvcG93ZXJzaGVsbC1tZXNzYWdlYm94LyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtNZXNzYWdlYm94" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3Bvd2Vyc2hlbGwtbWVzc2FnZWJveC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrTWVzc2FnZWJveA==" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS9wb3dlcnNoZWxsLW1lc3NhZ2Vib3gv" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3004" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/L7pt9Y3lDTk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/powershell-messagebox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/powershell-messagebox/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-messagebox</feedburner:origLink></item>
		<item>
		<title>Why Doesn’t My Pipeline Work?</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/AkOpXZlQgog/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/why-doesnt-my-pipeline-work/#comments</comments>
		<pubDate>Tue, 07 May 2013 13:01:35 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ForEach]]></category>
		<category><![CDATA[Pipeline]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=3000</guid>
		<description><![CDATA[I saw a little discussion thread on Twitter this morning which I felt needed a little more room to explain. Plus since we&#8217;re in ScriptingGames season beginners might like a few pointers. I always talk about PowerShell, objects and the pipeline. But sometimes what looks like a pipelined expression in the PowerShell ISE doesn&#8217;t behave [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDExLzEwL3RhbGtidWJibGUucG5nI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-thumbnail wp-image-1688" alt="talkbubble" src="http://jdhitsolutions.com/blog/wp-content/uploads/2011/10/talkbubble-150x150.png" width="150" height="150" /></a> I saw a little discussion thread on Twitter this morning which I felt needed a little more room to explain. Plus since we&#8217;re in <a title=\"Join the games\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NjcmlwdGluZ2dhbWVzLm9yZy9ob21lLnBocA==">ScriptingGames</a> season beginners might like a few pointers. I always talk about PowerShell, objects and the pipeline. But sometimes what looks like a pipelined expression in the PowerShell ISE doesn&#8217;t behave the way you might expect.</p>
<p>Here&#8217;s an example.</p><pre class="crayon-plain-tag">$c=0
While ($c -le 5) {
 $c
 $c++
}</pre><p></p>
<p>If you run this, you&#8217;ll see numbers 1 to 5 written to the pipeline. But if you try something like this it will fail.</p>
<p></p><pre class="crayon-plain-tag">$c=0
While ($c -le 5) {
 $c
 $c++
} | out-file foo.txt</pre><p> </p>
<p>You&#8217;ll get an error about an empty pipe. In fact, in the PowerShell ISE you&#8217;ll get a red squiggle under the | indicating this is not going to work. That&#8217;s because PowerShell isn&#8217;t writing to pipeline at the end of the scriptblock, but rather within in.  Another way to think about it is at the While operator is not a cmdlet so the only thing writing objects to the pipeline is whatever commands are within the While loop. </p>
<p>What you can do is something like this:</p>
<p></p><pre class="crayon-plain-tag">$c=0
$a = While ($c -le 5) {
 $c
 $c++
} 
$a | out-file foo.txt</pre><p> </p>
<p>Here, I&#8217;m capturing the pipeline output from the scriptblock and saving it to a variable. Then I have objects I can use. Or if you wanted to be clever, you could use a subexpression.</p>
<p></p><pre class="crayon-plain-tag">$c=0
$(While ($c -le 5) {
 $c
 $c++
}) | get-member</pre><p> </p>
<p>This same behavior also applies to Do and the ForEach enumerator. The latter trips people up all the time.</p>
<p></p><pre class="crayon-plain-tag">$i=1..5
foreach ($x in $i) {
  $x * 2
} | out-file results.txt</pre><p> </p>
<p>You think you&#8217;ll get the output of ForEach saved to the file, but you&#8217;ll run into the empty pipeline again. You could use a variable and then pipe the variable to the file or use a subexpression. Even better, use a pipelined expression.</p>
<p></p><pre class="crayon-plain-tag">1..5 | foreach {$_*2} | out-file results.txt</pre><p> </p>
<p>Here I&#8217;m using the cmdlet ForEach-Object, which unfortunately has an alias of ForEach which confuses PowerShell beginners. So don&#8217;t assume that just because you see a set of { }  that you get pipelined output. Remember, cmdlets write objects to the pipeline, not operators.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVdoeStEb2VzbiVFMiU4MCU5OXQrTXkrUGlwZWxpbmUrV29yayUzRitodHRwJTNBJTJGJTJGamRoaXRzb2x1dGlvbnMuY29tJTJGYmxvZyUyRjIwMTMlMkYwNSUyRndoeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yayUyRg==" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLyZhbXA7dGl0bGU9V2h5K0RvZXNuJUUyJTgwJTk5dCtNeStQaXBlbGluZStXb3JrJTNG" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLyZhbXA7dGl0bGU9V2h5K0RvZXNuJUUyJTgwJTk5dCtNeStQaXBlbGluZStXb3JrJTNG" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLyZhbXA7dD1XaHkrRG9lc24lRTIlODAlOTl0K015K1BpcGVsaW5lK1dvcmslM0Y=" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1XaHkrRG9lc24lRTIlODAlOTl0K015K1BpcGVsaW5lK1dvcmslM0YmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLw==" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9V2h5K0RvZXNuJUUyJTgwJTk5dCtNeStQaXBlbGluZStXb3JrJTNGJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3doeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yay8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytJK3NhdythK2xpdHRsZStkaXNjdXNzaW9uK3RocmVhZCtvbitUd2l0dGVyK3RoaXMrbW9ybmluZyt3aGljaCtJK2ZlbHQrbmVlZGVkK2ErbGl0dGxlK21vcmUrcm9vbSt0bytleHBsYWluLitQbHVzK3NpbmNlK3dlJTI3cmUraW4rU2NyaXB0aW5nR2FtZXMrc2VhLi4u" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9V2h5K0RvZXNuJUUyJTgwJTk5dCtNeStQaXBlbGluZStXb3JrJTNGJmFtcDtib2R5PUxpbms6K2h0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3doeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yay8lMEQlMEElMEQlMEEtLS0tJTBEJTBBKytJK3NhdythK2xpdHRsZStkaXNjdXNzaW9uK3RocmVhZCtvbitUd2l0dGVyK3RoaXMrbW9ybmluZyt3aGljaCtJK2ZlbHQrbmVlZGVkK2ErbGl0dGxlK21vcmUrcm9vbSt0bytleHBsYWluLitQbHVzK3NpbmNlK3dlJTI3cmUraW4rU2NyaXB0aW5nR2FtZXMrc2VhLi4u" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3doeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yay8mYW1wO3RpdGxlPVdoeStEb2VzbiVFMiU4MCU5OXQrTXkrUGlwZWxpbmUrV29yayUzRiZhbXA7c3VtbWFyeT0rSStzYXcrYStsaXR0bGUrZGlzY3Vzc2lvbit0aHJlYWQrb24rVHdpdHRlcit0aGlzK21vcm5pbmcrd2hpY2grSStmZWx0K25lZWRlZCthK2xpdHRsZSttb3JlK3Jvb20rdG8rZXhwbGFpbi4rUGx1cytzaW5jZSt3ZSUyN3JlK2luK1NjcmlwdGluZ0dhbWVzK3NlYS4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3doeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yay8mYW1wO3RpdGxlPVdoeStEb2VzbiVFMiU4MCU5OXQrTXkrUGlwZWxpbmUrV29yayUzRiZhbXA7c3VtbWFyeT0rSStzYXcrYStsaXR0bGUrZGlzY3Vzc2lvbit0aHJlYWQrb24rVHdpdHRlcit0aGlzK21vcm5pbmcrd2hpY2grSStmZWx0K25lZWRlZCthK2xpdHRsZSttb3JlK3Jvb20rdG8rZXhwbGFpbi4rUGx1cytzaW5jZSt3ZSUyN3JlK2luK1NjcmlwdGluZ0dhbWVzK3NlYS4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1XaHkrRG9lc24lRTIlODAlOTl0K015K1BpcGVsaW5lK1dvcmslM0YmYW1wO2xpbms9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLw==" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS93aHktZG9lc250LW15LXBpcGVsaW5lLXdvcmsvJmFtcDt0aXRsZT1XaHkrRG9lc24lRTIlODAlOTl0K015K1BpcGVsaW5lK1dvcmslM0Y=" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvd2h5LWRvZXNudC1teS1waXBlbGluZS13b3JrLyZhbXA7dGl0bGU9V2h5K0RvZXNuJUUyJTgwJTk5dCtNeStQaXBlbGluZStXb3JrJTNG" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3doeS1kb2VzbnQtbXktcGlwZWxpbmUtd29yay8mYW1wO3RpdGxlPVdoeStEb2VzbiVFMiU4MCU5OXQrTXkrUGlwZWxpbmUrV29yayUzRg==" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS93aHktZG9lc250LW15LXBpcGVsaW5lLXdvcmsv" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=3000" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/AkOpXZlQgog" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/why-doesnt-my-pipeline-work/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/why-doesnt-my-pipeline-work/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=why-doesnt-my-pipeline-work</feedburner:origLink></item>
		<item>
		<title>TechDays SF Presentations</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/Waqhj9exEyw/</link>
		<comments>http://jdhitsolutions.com/blog/2013/05/techdays-sf-presentations/#comments</comments>
		<pubDate>Mon, 06 May 2013 11:35:31 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[Powershell 3.0]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Server 2012]]></category>
		<category><![CDATA[WMI]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[TechDays]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=2988</guid>
		<description><![CDATA[Last week I presented a number of sessions at TechDays in beautiful San Francisco. Met some great people and had a great time. I presented 4 talks, almost all of them PowerShell-related. Actually, they all had some type of PowerShell content. I&#8217;m happy to share my session slides and PowerShell demonstrations. Most of the demonstrations [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L1RlY2hEYXlzX2xvZ28yNTAuZ2lmI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA=="><img class="alignleft size-full wp-image-2989" alt="TechDays_logo250" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/05/TechDays_logo250.gif" width="250" height="170" /></a> Last week I presented a number of sessions at TechDays in beautiful San Francisco. Met some great people and had a great time. I presented 4 talks, almost all of them PowerShell-related. Actually, they all had some type of PowerShell content. I&#8217;m happy to share my session slides and PowerShell demonstrations. Most of the demonstrations are not full-blown scripts but command examples, except for those things labeled as functions. If you did not attend TechDays, you are still welcome to download the material, although without the context of the live presentation some of it may not make sense. I hope you can make it next time.</p>
<p><em><a title=\"download the zip file\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L0ZpbGUtYW5kLUZvbGRlcnMtd2l0aC1Qb3dlcnNoZWxsLTMuemlwI3V0bV9zb3VyY2U9ZmVlZCZhbXA7dXRtX21lZGl1bT1mZWVkJmFtcDt1dG1fY2FtcGFpZ249ZmVlZA==">File and Folders with Powershell 3</a></em><br />
If you manage file servers and aren&#8217;t using PowerShell, you are working much too hard. Or if you are using PowerShell v2 you are still working pretty hard. Fortunately PowerShell v3 along with Windows 8 and Windows Server 2012 offer a much better solution. This session will demonstrate how to provision and manage folders, files and file shares using PowerShell from a Windows 8 client. With a little up-front work, you &#8216;ll be able to create provisioning scripts to deploy a new file share in seconds.</p>
<p><em><a title=\"download the zip file\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1LzEwLVBvd2VyU2hlbGwtbWlzdGFrZXMtdHJpcC11cHMtYW5kLXRyYXBzLnppcCN1dG1fc291cmNlPWZlZWQmYW1wO3V0bV9tZWRpdW09ZmVlZCZhbXA7dXRtX2NhbXBhaWduPWZlZWQ=">10 PowerShell mistakes, trip-ups and traps</a></em><br />
Windows PowerShell is a language and management technology that many IT professionals, including developers, think they understand. Yet very often they get caught up in pre-conceptions and misinterpretations, usually based on prior experience with scripting or development. This session will explore the 10 most common mistakes and traps that people fall into with PowerShell and how to avoid them.</p>
<p><em><a title=\"download the zip file\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L1Ryb3VibGVzaG9vdGluZy1BY3RpdmUtRGlyZWN0b3J5LXdpdGgtUG93ZXJTaGVsbC56aXAjdXRtX3NvdXJjZT1mZWVkJmFtcDt1dG1fbWVkaXVtPWZlZWQmYW1wO3V0bV9jYW1wYWlnbj1mZWVk">Troubleshooting Active Directory with PowerShell</a></em><br />
Active Directory is one of those technologies that when it works, nobody notices. But when it doesn&#8217;t work, everyone does. Fortunately, Windows PowerShell and Windows Server 2012 make a terrific troubleshooting tool. In this session we&#8217;ll look at some common Active Directory problems, how to diagnose them and in some cases resolve, all with Windows PowerShell.</p>
<p><em><a title=\"download the zip file\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L0J1aWxkaW5nLWEtV2luZG93cy04LUh5cGVyLVYtbGFiLnppcCN1dG1fc291cmNlPWZlZWQmYW1wO3V0bV9tZWRpdW09ZmVlZCZhbXA7dXRtX2NhbXBhaWduPWZlZWQ=">Building a Windows 8 Hyper-V lab</a></em><br />
We all know the benefits of testing in a non-production environment. But sometimes resources are limited and having a test setup seems like a lot of work. But now that Windows 8 includes Hyper-V, you can setup a lab environment in very little time. This session will guide you through setting up a Hyper-V based test lab and how to get the most out of it using the PowerShell management tools.</p>
<p>If you didn&#8217;t catch me in San Francisco, I&#8217;ll be at TechMentor this fall in Las Vegas. More on that later. There&#8217;s a chance I&#8217;ll be back to the West coast later this year for more PowerShell goodness. Keep an eye on the blog for announcments. Or if your company is looking for training, <a href="mailto:jhicks@jdhitsolutions.com?Subject=Let"s talk training#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed\" title=\"shoot me an email\" target=\"_blank\">let&#8217;s talk</a>.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVRlY2hEYXlzK1NGK1ByZXNlbnRhdGlvbnMraHR0cCUzQSUyRiUyRmpkaGl0c29sdXRpb25zLmNvbSUyRmJsb2clMkYyMDEzJTJGMDUlMkZ0ZWNoZGF5cy1zZi1wcmVzZW50YXRpb25zJTJG" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVjaGRheXMtc2YtcHJlc2VudGF0aW9ucy8mYW1wO3RpdGxlPVRlY2hEYXlzK1NGK1ByZXNlbnRhdGlvbnM=" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVjaGRheXMtc2YtcHJlc2VudGF0aW9ucy8mYW1wO3RpdGxlPVRlY2hEYXlzK1NGK1ByZXNlbnRhdGlvbnM=" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVjaGRheXMtc2YtcHJlc2VudGF0aW9ucy8mYW1wO3Q9VGVjaERheXMrU0YrUHJlc2VudGF0aW9ucw==" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1UZWNoRGF5cytTRitQcmVzZW50YXRpb25zJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3RlY2hkYXlzLXNmLXByZXNlbnRhdGlvbnMv" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9VGVjaERheXMrU0YrUHJlc2VudGF0aW9ucyZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZWNoZGF5cy1zZi1wcmVzZW50YXRpb25zLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErK0xhc3Qrd2VlaytJK3ByZXNlbnRlZCthK251bWJlcitvZitzZXNzaW9ucythdCtUZWNoRGF5cytpbitiZWF1dGlmdWwrU2FuK0ZyYW5jaXNjby4rTWV0K3NvbWUrZ3JlYXQrcGVvcGxlK2FuZCtoYWQrYStncmVhdCt0aW1lLitJK3ByZXNlbnRlZCs0K3RhbGtzLi4u" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9VGVjaERheXMrU0YrUHJlc2VudGF0aW9ucyZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZWNoZGF5cy1zZi1wcmVzZW50YXRpb25zLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErK0xhc3Qrd2VlaytJK3ByZXNlbnRlZCthK251bWJlcitvZitzZXNzaW9ucythdCtUZWNoRGF5cytpbitiZWF1dGlmdWwrU2FuK0ZyYW5jaXNjby4rTWV0K3NvbWUrZ3JlYXQrcGVvcGxlK2FuZCtoYWQrYStncmVhdCt0aW1lLitJK3ByZXNlbnRlZCs0K3RhbGtzLi4u" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3RlY2hkYXlzLXNmLXByZXNlbnRhdGlvbnMvJmFtcDt0aXRsZT1UZWNoRGF5cytTRitQcmVzZW50YXRpb25zJmFtcDtzdW1tYXJ5PStMYXN0K3dlZWsrSStwcmVzZW50ZWQrYStudW1iZXIrb2Yrc2Vzc2lvbnMrYXQrVGVjaERheXMraW4rYmVhdXRpZnVsK1NhbitGcmFuY2lzY28uK01ldCtzb21lK2dyZWF0K3Blb3BsZSthbmQraGFkK2ErZ3JlYXQrdGltZS4rSStwcmVzZW50ZWQrNCt0YWxrcy4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3RlY2hkYXlzLXNmLXByZXNlbnRhdGlvbnMvJmFtcDt0aXRsZT1UZWNoRGF5cytTRitQcmVzZW50YXRpb25zJmFtcDtzdW1tYXJ5PStMYXN0K3dlZWsrSStwcmVzZW50ZWQrYStudW1iZXIrb2Yrc2Vzc2lvbnMrYXQrVGVjaERheXMraW4rYmVhdXRpZnVsK1NhbitGcmFuY2lzY28uK01ldCtzb21lK2dyZWF0K3Blb3BsZSthbmQraGFkK2ErZ3JlYXQrdGltZS4rSStwcmVzZW50ZWQrNCt0YWxrcy4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1UZWNoRGF5cytTRitQcmVzZW50YXRpb25zJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3RlY2hkYXlzLXNmLXByZXNlbnRhdGlvbnMv" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZWNoZGF5cy1zZi1wcmVzZW50YXRpb25zLyZhbXA7dGl0bGU9VGVjaERheXMrU0YrUHJlc2VudGF0aW9ucw==" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDUvdGVjaGRheXMtc2YtcHJlc2VudGF0aW9ucy8mYW1wO3RpdGxlPVRlY2hEYXlzK1NGK1ByZXNlbnRhdGlvbnM=" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA1L3RlY2hkYXlzLXNmLXByZXNlbnRhdGlvbnMvJmFtcDt0aXRsZT1UZWNoRGF5cytTRitQcmVzZW50YXRpb25z" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNS90ZWNoZGF5cy1zZi1wcmVzZW50YXRpb25zLw==" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=2988" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/Waqhj9exEyw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/05/techdays-sf-presentations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/05/techdays-sf-presentations/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=techdays-sf-presentations</feedburner:origLink></item>
		<item>
		<title>PowerShell PopUp</title>
		<link>http://feedproxy.google.com/~r/JeffsScriptingBlogAndMore/~3/9XJ4kLgtk_s/</link>
		<comments>http://jdhitsolutions.com/blog/2013/04/powershell-popup/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 13:35:22 +0000</pubDate>
		<dc:creator>Jeffery Hicks</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[PSHSummit]]></category>

		<guid isPermaLink="false">http://jdhitsolutions.com/blog/?p=2976</guid>
		<description><![CDATA[At the recent PowerShell Summit I presented a session on adding graphical elements to your script without the need for WinForms or WPF. One of the items I demonstrated is a graphical popup that can either require the user to click a button or automatically dismiss after a set time period. If this sounds familiar, [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA0L3BvcHVwLnBuZyN1dG1fc291cmNlPWZlZWQmYW1wO3V0bV9tZWRpdW09ZmVlZCZhbXA7dXRtX2NhbXBhaWduPWZlZWQ="><img class="alignleft size-medium wp-image-2977" alt="popup" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/04/popup-300x139.png" width="300" height="139" /></a>At the recent PowerShell Summit I presented a session on adding graphical elements to your script without the need for WinForms or WPF. One of the items I demonstrated is a graphical popup that can either require the user to click a button or automatically dismiss after a set time period. If this sounds familiar, yes, it is our old friend VBScript and the Popup method of the Wscript.Shell object. Because PowerShell can create and use COM objects, why not take advantage of this?</p>
<p>All it really takes is two lines. One line to create the Wscript.Shell COM object and one to invoke the Popup method.  (Yes, I&#8217;m sure you could do this in one line, but that&#8217;s not the point.)</p><pre class="crayon-plain-tag">$wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
$wshell.Popup("Are you looking at me?",0,"Hey!",48+4)</pre><p>The Popup method needs parameters for the message, title, a timeout value, and an integer value that represents a combination of buttons and icons.</p>
<p><a href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA0L3BvcHVwMi5wbmcjdXRtX3NvdXJjZT1mZWVkJmFtcDt1dG1fbWVkaXVtPWZlZWQmYW1wO3V0bV9jYW1wYWlnbj1mZWVk"><img class="aligncenter size-full wp-image-2978" alt="popup2" src="http://jdhitsolutions.com/blog/wp-content/uploads/2013/04/popup2.png" width="251" height="172" /></a>The challenging part has always been trying to remember the integer values. So I wrote a quick function called New-Popup.</p><pre class="crayon-plain-tag">#requires -version 2.0

Function New-Popup {

&lt;#
.Synopsis
Display a Popup Message
.Description
This command uses the Wscript.Shell PopUp method to display a graphical message
box. You can customize its appearance of icons and buttons. By default the user
must click a button to dismiss but you can set a timeout value in seconds to 
automatically dismiss the popup. 

The command will write the return value of the clicked button to the pipeline:
  OK     = 1
  Cancel = 2
  Abort  = 3
  Retry  = 4
  Ignore = 5
  Yes    = 6
  No     = 7

If no button is clicked, the return value is -1.
.Example
PS C:\&gt; new-popup -message "The update script has completed" -title "Finished" -time 5

This will display a popup message using the default OK button and default 
Information icon. The popup will automatically dismiss after 5 seconds.
.Notes
Last Updated: April 8, 2013
Version     : 1.0

.Inputs
None
.Outputs
integer

Null   = -1
OK     = 1
Cancel = 2
Abort  = 3
Retry  = 4
Ignore = 5
Yes    = 6
No     = 7
#&gt;

Param (
[Parameter(Position=0,Mandatory=$True,HelpMessage="Enter a message for the popup")]
[ValidateNotNullorEmpty()]
[string]$Message,
[Parameter(Position=1,Mandatory=$True,HelpMessage="Enter a title for the popup")]
[ValidateNotNullorEmpty()]
[string]$Title,
[Parameter(Position=2,HelpMessage="How many seconds to display? Use 0 require a button click.")]
[ValidateScript({$_ -ge 0})]
[int]$Time=0,
[Parameter(Position=3,HelpMessage="Enter a button group")]
[ValidateNotNullorEmpty()]
[ValidateSet("OK","OKCancel","AbortRetryIgnore","YesNo","YesNoCancel","RetryCancel")]
[string]$Buttons="OK",
[Parameter(Position=4,HelpMessage="Enter an icon set")]
[ValidateNotNullorEmpty()]
[ValidateSet("Stop","Question","Exclamation","Information" )]
[string]$Icon="Information"
)

#convert buttons to their integer equivalents
Switch ($Buttons) {
    "OK"               {$ButtonValue = 0}
    "OKCancel"         {$ButtonValue = 1}
    "AbortRetryIgnore" {$ButtonValue = 2}
    "YesNo"            {$ButtonValue = 4}
    "YesNoCancel"      {$ButtonValue = 3}
    "RetryCancel"      {$ButtonValue = 5}
}

#set an integer value for Icon type
Switch ($Icon) {
    "Stop"        {$iconValue = 16}
    "Question"    {$iconValue = 32}
    "Exclamation" {$iconValue = 48}
    "Information" {$iconValue = 64}
}

#create the COM Object
Try {
    $wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
    #Button and icon type values are added together to create an integer value
    $wshell.Popup($Message,$Time,$Title,$ButtonValue+$iconValue)
}
Catch {
    #You should never really run into an exception in normal usage
    Write-Warning "Failed to create Wscript.Shell COM object"
    Write-Warning $_.exception.message
}

} #end function</pre><p>The function lets you use text descriptions for the buttons and icons. In PowerShell 3.0 you will also get tab completion for the possible values. This makes it easy to create a command like this:</p><pre class="crayon-plain-tag">new-popup "Do you want to get work done with PowerShell?" -Title "Hey, you!" -Buttons YesNo -Icon Question</pre><p>The function writes the value of the clicked button to the pipeline. I expect this is something you are more apt to use in a script. Perhaps to display an error message or even to prompt the user for an action. Maybe you&#8217;d like to use it in your PowerShell 3.0 profile:</p><pre class="crayon-plain-tag">$r = New-Popup -Title "Help Update" -Message "Do you want to update help now?" -Buttons YesNo -Time 5 -Icon Question
if ($r -eq 6) {
  Update-Help -SourcePath \\jdh-nvnas\files\PowerShell_Help -Force
}</pre><p>The popup will automatically dismiss after 5 seconds unless I click Yes or No. You should be able to copy the function text from the listing above by toggling to plain code, select all and copy.</p>
<p>I hope you&#8217;ll let me know where you use this.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3R3aXR0ZXIuY29tL2ludGVudC90d2VldD90ZXh0PVBvd2VyU2hlbGwrUG9wVXAraHR0cCUzQSUyRiUyRmpkaGl0c29sdXRpb25zLmNvbSUyRmJsb2clMkYyMDEzJTJGMDQlMkZwb3dlcnNoZWxsLXBvcHVwJTJG" title=\"Post to Twitter\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BsdXJrLmNvbS8/c3RhdHVzPSU1QkJMQU5LJTVE" title=\"Post to Plurk\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/plurk/tt-plurk.png" alt="Post to Plurk" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RlbGljaW91cy5jb20vcG9zdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDQvcG93ZXJzaGVsbC1wb3B1cC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrUG9wVXA=" title=\"Post to Delicious\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL2RpZ2cuY29tL3N1Ym1pdD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDQvcG93ZXJzaGVsbC1wb3B1cC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrUG9wVXA=" title=\"Post to Digg\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mYWNlYm9vay5jb20vc2hhcmUucGhwP3U9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDQvcG93ZXJzaGVsbC1wb3B1cC8mYW1wO3Q9UG93ZXJTaGVsbCtQb3BVcA==" title=\"Post to Facebook\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5mcmllbmRmZWVkLmNvbS9zaGFyZT90aXRsZT1Qb3dlclNoZWxsK1BvcFVwJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA0L3Bvd2Vyc2hlbGwtcG9wdXAv" title=\"Post to FriendFeed\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ff/tt-ff.png" alt="Post to FriendFeed" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtQb3BVcCZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNC9wb3dlcnNoZWxsLXBvcHVwLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErQXQrdGhlK3JlY2VudCtQb3dlclNoZWxsK1N1bW1pdCtJK3ByZXNlbnRlZCthK3Nlc3Npb24rb24rYWRkaW5nK2dyYXBoaWNhbCtlbGVtZW50cyt0byt5b3VyK3NjcmlwdCt3aXRob3V0K3RoZStuZWVkK2ZvcitXaW5Gb3JtcytvcitXUEYuK09uZStvZit0aGUrLi4u" title=\"Send Gmail\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/gmail/tt-gmail.png" alt="Send Gmail" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC8/dWk9MiZhbXA7dmlldz1jbSZhbXA7ZnM9MSZhbXA7dGY9MSZhbXA7c3U9UG93ZXJTaGVsbCtQb3BVcCZhbXA7Ym9keT1MaW5rOitodHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNC9wb3dlcnNoZWxsLXBvcHVwLyUwRCUwQSUwRCUwQS0tLS0lMEQlMEErQXQrdGhlK3JlY2VudCtQb3dlclNoZWxsK1N1bW1pdCtJK3ByZXNlbnRlZCthK3Nlc3Npb24rb24rYWRkaW5nK2dyYXBoaWNhbCtlbGVtZW50cyt0byt5b3VyK3NjcmlwdCt3aXRob3V0K3RoZStuZWVkK2ZvcitXaW5Gb3JtcytvcitXUEYuK09uZStvZit0aGUrLi4u" title=\"Send Gmail\">Send Gmail</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA0L3Bvd2Vyc2hlbGwtcG9wdXAvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1BvcFVwJmFtcDtzdW1tYXJ5PUF0K3RoZStyZWNlbnQrUG93ZXJTaGVsbCtTdW1taXQrSStwcmVzZW50ZWQrYStzZXNzaW9uK29uK2FkZGluZytncmFwaGljYWwrZWxlbWVudHMrdG8reW91citzY3JpcHQrd2l0aG91dCt0aGUrbmVlZCtmb3IrV2luRm9ybXMrb3IrV1BGLitPbmUrb2YrdGhlKy4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin.png" alt="Post to LinkedIn" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rZWRpbi5jb20vc2hhcmVBcnRpY2xlP21pbmk9dHJ1ZSZhbXA7dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA0L3Bvd2Vyc2hlbGwtcG9wdXAvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1BvcFVwJmFtcDtzdW1tYXJ5PUF0K3RoZStyZWNlbnQrUG93ZXJTaGVsbCtTdW1taXQrSStwcmVzZW50ZWQrYStzZXNzaW9uK29uK2FkZGluZytncmFwaGljYWwrZWxlbWVudHMrdG8reW91citzY3JpcHQrd2l0aG91dCt0aGUrbmVlZCtmb3IrV2luRm9ybXMrb3IrV1BGLitPbmUrb2YrdGhlKy4uLiZhbXA7c291cmNlPVRoZSBMb25lbHkgQWRtaW5pc3RyYXRvcg==" title=\"Post to LinkedIn\">Post to LinkedIn</a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3BpbmcuZm0vcmVmLz9tZXRob2Q9bWljcm9ibG9nJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1BvcFVwJmFtcDtsaW5rPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA0L3Bvd2Vyc2hlbGwtcG9wdXAv" title=\"Post to Ping.fm\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/ping/tt-ping.png" alt="Post to Ping.fm" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3JlZGRpdC5jb20vc3VibWl0P3VybD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNC9wb3dlcnNoZWxsLXBvcHVwLyZhbXA7dGl0bGU9UG93ZXJTaGVsbCtQb3BVcA==" title=\"Post to Reddit\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3NsYXNoZG90Lm9yZy9ib29rbWFyay5wbD91cmw9aHR0cDovL2pkaGl0c29sdXRpb25zLmNvbS9ibG9nLzIwMTMvMDQvcG93ZXJzaGVsbC1wb3B1cC8mYW1wO3RpdGxlPVBvd2VyU2hlbGwrUG9wVXA=" title=\"Post to Slashdot\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/slashdot/tt-slashdot.png" alt="Post to Slashdot" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3N0dW1ibGV1cG9uLmNvbS9zdWJtaXQ/dXJsPWh0dHA6Ly9qZGhpdHNvbHV0aW9ucy5jb20vYmxvZy8yMDEzLzA0L3Bvd2Vyc2hlbGwtcG9wdXAvJmFtcDt0aXRsZT1Qb3dlclNoZWxsK1BvcFVw" title=\"Post to StumbleUpon\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a target=\"_blank\" class=\"tt\" href="http://jdhitsolutions.com/blog/?feed-stats-url=aHR0cDovL3RlY2hub3JhdGkuY29tL2ZhdmVzP2FkZD1odHRwOi8vamRoaXRzb2x1dGlvbnMuY29tL2Jsb2cvMjAxMy8wNC9wb3dlcnNoZWxsLXBvcHVwLw==" title=\"Post to Technorati\"><img class="nothumb" src="http://jdhitsolutions.com/blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati.png" alt="Post to Technorati" /></a></p></div> <img src="http://jdhitsolutions.com/blog/?feed-stats-post-id=2976" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/JeffsScriptingBlogAndMore/~4/9XJ4kLgtk_s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jdhitsolutions.com/blog/2013/04/powershell-popup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://jdhitsolutions.com/blog/2013/04/powershell-popup/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-popup</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 6.591 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-18 18:05:17 -->
