Skip to main content

Posts

Showing posts from November, 2014

Giving Thanks

This post may be a little off topic, so please bare with me. These past few weeks I have been providing Windows and PowerShell training in Asia and the south Pacific. We took a longer than usual lunch break yesterday so the Sailors of the United States Navy in my class can enjoy the one Thanksgiving meal that they will get this year. What ever nation you claim as your own, please remember your sons and daughters who have volunteered to spend their time away from their families so you can be free to spend time with yours. Not far from where I am right now, freedom is only a distant light on the horizon. A beacon of hope for a brighter future. Be thankful that you may stand in that light and not gaze at it from a distance. To all of my Brothers and Sisters who have volunteered to keep us all free,  Happy Thanksgiving.

Adding properties to PowerShell Output

This morning on PowerShell.com, I helped with a question about adding data to an output.  Essentially, there were two data sources and the user needed the data to be presented in one object so they could pipe it to Export-CSV.  The Select-Object cmdlet has the ability to add data to an object.  Take a look at this code. 1 2 3 4 5 6 7 8 9 10 11 12 13   $Servers = "Server1" , "Server2" $MasterArray = @() ForEach ( $Server in $Servers ) {       If ( Test-Connection -quiet -computer $server )     {     $Result = Get-Counter -Counter "\\ $server \Processor Information(_Total)\% Processor Time"     $Result | Select-Object -Property * ,         @{N = "Online" ;E = { $True }}     }   }   This is the complete code.  What was missing was lines 9 and 10.  Lines 9 and 10 are actually the same lin...