{"id":1369,"date":"2011-04-25T13:01:25","date_gmt":"2011-04-25T17:01:25","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1369"},"modified":"2011-04-26T06:47:26","modified_gmt":"2011-04-26T10:47:26","slug":"scripting-games-2001-beginner-event-5-commentary","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/","title":{"rendered":"Scripting Games 2011 Beginner Event 5 Commentary"},"content":{"rendered":"<p>My commentary for Beginner Event 5 in the 2011 Scripting Games is <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/04\/22\/expert-solution-for-2011-scripting-games-beginner-event-5-use-powershell-objects-to-gather-basic-computer-information.aspx\" target=\"_blank\">now available<\/a>. One item that seems to be missing on the ScriptingGuys site is my complete solution so I thought I would share it here, plus a variation.<!--more--><\/p>\n<p>My sample solution is perhaps a little over-wrought for a beginner level script, but I wanted to demonstrate what I felt were some inportant scripting techiniques.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\n#Requires -version 2.0 <\/p>\n<p>#You need to collect the user name, computer name, domain name, and the operating system information<br \/>\n#from a number of computers. To make matters easier, you have decided to write the information to a<br \/>\n#text file. The text file needs to be saved as an ASCII file, and not as Unicode. You should include<br \/>\n#the date in which the information was gathered to determine reliability of the information.<\/p>\n<p>#Design points<br \/>\n#\tExtra points for a script that will work against a remote machine<br \/>\n#\tExtra points for a script that will accept a Text file, CSV or other type of input of remote computer names<br \/>\n#\tExtra points for adding useful help information and comments<br \/>\n#\tDesign points for clear easy to read code, and use of native Windows PowerShell cmdlets<\/p>\n<p>Param (<br \/>\n [string]$File=\"computers.txt\",<br \/>\n [string]$LogFile=\"ComputerReport.txt\",<br \/>\n [string]$ErrorLog=\"failed.txt\",<br \/>\n [Switch]$Append<br \/>\n )<\/p>\n<p>Set-StrictMode -Version 2<\/p>\n<p>#Verify list of computers exists<br \/>\nIf (Test-Path -Path $File)<br \/>\n{<\/p>\n<p>    #if error log already exists, delete it so we get a new file<br \/>\n    if (Test-Path -Path $ErrorLog)<br \/>\n    {<br \/>\n        Remove-Item -Path $ErrorLog<br \/>\n    }<br \/>\n    #retrieve computer names filtering out any blank lines<br \/>\n    $Computers=Get-Content -Path $file | Where {$_}<\/p>\n<p>    Write-Host \"Gathering computer information. Please wait...\" -ForegroundColor Cyan<br \/>\n    #initialize an array to hold computer information<br \/>\n    $data=@()<\/p>\n<p>    #for each computer in the list<br \/>\n    Foreach ($Computer in $Computers) {<\/p>\n<p>        #trim off any spaces<br \/>\n        $Computer=$Computer.Trim()<\/p>\n<p>        #write the computername to the console as a status message<br \/>\n        Write-Host $Computer.toUpper() -ForegroundColor Cyan<\/p>\n<p>        #ping the computer using Test-Connection. I'm saving the results to a variable<br \/>\n        #so that I can get the IP address. I set the ErrorAction preference to SilentlyContinue<br \/>\n        #to suppress error messages<br \/>\n        $ping=Test-Connection -ComputerName $Computer -Count 2 -ErrorAction \"SilentlyContinue\"<br \/>\n        if ($ping)<br \/>\n        {<br \/>\n            #if the computer is pingable get WMI information<br \/>\n            Try<br \/>\n            {<br \/>\n                #attempt to retrieve WMI information and if there is an error catch it<br \/>\n                $OperatingSystem=Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -ErrorAction Stop<br \/>\n                $ComputerSystem=Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer -ErrorAction Stop<\/p>\n<p>                #only process if WMI queries were sucessful<br \/>\n                if ($OperatingSystem -AND $ComputerSystem)<br \/>\n                {<br \/>\n                    #create a custom object using a property hash table<br \/>\n                    #I'm including ServicePack information since that might come in handy<br \/>\n                    $data+=New-Object -TypeName PSObject -Property @{<br \/>\n                        User=$ComputerSystem.UserName<br \/>\n                        Commputer=$OperatingSystem.CSName<br \/>\n                        IPAddress=$ping[0].ipv4address.ToString()<br \/>\n                        Domain=$ComputerSystem.Domain<br \/>\n                        OS=$OperatingSystem.Caption<br \/>\n                        ServicePack=$OperatingSystem.ServicePackMajorVersion<br \/>\n                        Model=$ComputerSystem.Model<br \/>\n                        Reported=(Get-Date)<br \/>\n                    }<br \/>\n                }<br \/>\n                else<br \/>\n                {<br \/>\n                    #otherwise record the failure in a log file<br \/>\n                    $Computer.ToUpper() | Add-Content -Path $ErrorLog<br \/>\n                }<br \/>\n            } #close Try<\/p>\n<p>            Catch<br \/>\n            {<br \/>\n                Write-Warning \"There was a problem retrieving information from $($Computer.ToUpper())\"<br \/>\n                #write the exception message as a warning<br \/>\n                Write-Warning $_.Exception.Message<br \/>\n                #write the failed computername to a text file<br \/>\n                $computer.ToUpper() | Add-Content -Path $ErrorLog<br \/>\n            } #close Catch scriptblock<br \/>\n         } #if pingable<br \/>\n         else<br \/>\n         {<br \/>\n            #computer is not pingable<br \/>\n            $Computer.ToUpper() | Add-Content -Path $ErrorLog<br \/>\n         }<br \/>\n    } #foreach<\/p>\n<p>     #measure how many computers were queried and save the count property to a variable<br \/>\n     $count=($data | measure-object).Count<br \/>\n     Write-Host \"Successfully queried $Count computers.\" -ForegroundColor Cyan<br \/>\n     #write the WMI information to a log file if $data has anything in it<br \/>\n     if ($count -gt 0)<br \/>\n     {<br \/>\n        #if a file was specified then record information<br \/>\n        if ($LogFile -AND $Append)<br \/>\n        {<br \/>\n            $data | Out-File -FilePath $LogFile -Encoding ASCII -Append<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            $data | Out-File -FilePath $LogFile -Encoding ASCII<br \/>\n        }<br \/>\n     } #if $count greater than 0<\/p>\n<p>     Write-Host \"See $LogFile for details and $ErrorLog for failed computers.\" -ForegroundColor Cyan<br \/>\n} #if file exisits<\/p>\n<p>else<br \/>\n{<br \/>\n    #Failed to verify text file of computers<br \/>\n    Write-Warning \"Cannot find or verify $file.\"<br \/>\n}<\/p>\n<p>#end of script<br \/>\n[\/cc]<\/p>\n<p>I also wrote an \"advanced\" version with comment based help and one that accepts pipelined input. I've ommitted help section here but it is in the file you can download at the end.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\nFunction Get-ComputerInfo {<\/p>\n<p>[cmdletBinding()]<\/p>\n<p>Param (<br \/>\n    [Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]<br \/>\n    [ValidateNotNullorEmpty()]<br \/>\n    [Alias(\"name\")]<br \/>\n    [string[]]$Computername=$env:Computername,<\/p>\n<p>    [Parameter(Position=1,Mandatory=$False,HelpMessage=\"Enter the full filename and path for your report.\")]<br \/>\n    [string]$FilePath,<\/p>\n<p>    [switch]$Append,<\/p>\n<p>    [string]$ErrorLog=\"Failed.txt\"<\/p>\n<p>)<\/p>\n<p>Begin<br \/>\n{<br \/>\n    Set-StrictMode -Version 2<br \/>\n    Write-Verbose \"$(Get-Date) Starting script\"<br \/>\n    Write-Host \"Gathering computer information. Please wait...\" -ForegroundColor Cyan<br \/>\n    #initialize an array to hold computer information<br \/>\n    $data=@()<\/p>\n<p>} #close Begin scriptblock<\/p>\n<p>Process<br \/>\n{<br \/>\n    #process the array of computernames either piped in or passes as parameter values<br \/>\n    Foreach ($computer in $computername) {<br \/>\n        Try<br \/>\n        {<br \/>\n            Write-Verbose \"$(Get-Date) Getting information from $($Computer.toUpper())\"<\/p>\n<p>            #write a progress message on the console if a file path was specified<br \/>\n            #otherwise nothing is displayed which for a long running command migh<br \/>\n            #lead the user to think something is wrong. When a file is not used each<br \/>\n            #computer is written to the console<br \/>\n            if ($Filepath)<br \/>\n            {<br \/>\n                Write-Host $Computer.toUpper() -ForegroundColor Cyan<br \/>\n            }<\/p>\n<p>            #attempt to retrieve WMI information and if there is an error catch it<br \/>\n            $OperatingSystem=Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -ErrorAction Stop<br \/>\n            $ComputerSystem=Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer -ErrorAction Stop<\/p>\n<p>            #only process if WMI queries were sucessful<br \/>\n            if ($OperatingSystem -AND $ComputerSystem)<br \/>\n            {<br \/>\n                #create a custom object using a property hash table<br \/>\n                #I'm including ServicePack information since that might come in handy<br \/>\n                $object=New-Object -TypeName PSObject -Property @{<br \/>\n                    User=$ComputerSystem.UserName<br \/>\n                    Commputer=$OperatingSystem.CSName<br \/>\n                    Domain=$ComputerSystem.Domain<br \/>\n                    OS=$OperatingSystem.Caption<br \/>\n                    ServicePack=$OperatingSystem.ServicePackMajorVersion<br \/>\n                    Model=$ComputerSystem.Model<br \/>\n                    Reported=(Get-Date)<br \/>\n                } <\/p>\n<p>                if ($FilePath)<br \/>\n                {<br \/>\n                    #add the object to the data array in case we want to save it to a file<br \/>\n                    $data+=$object<br \/>\n                }<br \/>\n                else<br \/>\n                {<br \/>\n                    #Otherwise write the new object to the pipeline<br \/>\n                    Write-Output $object<br \/>\n                }<\/p>\n<p>            }<br \/>\n            else<br \/>\n            {<br \/>\n                #display a warning if the WMI information is not present. This should never really<br \/>\n                #be reached.<br \/>\n                Write-Warning \"There was an unknown problem. Not all information was available.\"<br \/>\n            }<br \/>\n        } #close Try scriptblock<\/p>\n<p>        Catch<br \/>\n        {<br \/>\n            Write-Warning \"There was a problem retrieving information from $($Computer.ToUpper())\"<br \/>\n            #write the exception message as a warning<br \/>\n            Write-Warning $_.Exception.Message<br \/>\n            #write the failed computername to a text file<br \/>\n            $computer.toUpper() | Add-Content -Path $ErrorLog<br \/>\n        } #close Catch scriptblock<br \/>\n    } #close Foreach<br \/>\n} #close Process script block<\/p>\n<p>End<br \/>\n{<br \/>\n    #if a file was specified then record information<br \/>\n    if ($FilePath -AND $Append)<br \/>\n    {<br \/>\n        Write-Verbose \"$(Get-Date) Appending to $filepath\"<br \/>\n        $data | Out-File -FilePath $Filepath -Encoding ASCII -Append<br \/>\n    }<br \/>\n    elseif ($FilePath)<br \/>\n    {<br \/>\n        Write-Verbose \"$(Get-Date) Writing data to $filepath\"<br \/>\n        $data | Out-File -FilePath $Filepath -Encoding ASCII<br \/>\n    }<br \/>\n    Write-Verbose \"$(Get-Date) Ending script\"<br \/>\n} #close End scriptblock<\/p>\n<p>} #end Function<\/p>\n<p>#end of script<br \/>\n[\/cc]<\/p>\n<p>Fundamentally, the code hasn't really changed except for the way I handle pipelined objects and the use of Write-Verbose to display status messages.<\/p>\n<p>Download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/Beg_5_2011.txt' target='_blank'>Beg_5_2011.ps1<\/a> and <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/Beg_5_2011_Variation.txt' target='_blank'>Beg_5_2011_Variation.ps1<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My commentary for Beginner Event 5 in the 2011 Scripting Games is now available. One item that seems to be missing on the ScriptingGuys site is my complete solution so I thought I would share it here, plus a variation.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,75,8,19],"tags":[32,280,190,534,279,547],"class_list":["post-1369","post","type-post","status-publish","format-standard","hentry","category-powershell","category-powershell-v2-0","category-scripting","category-wmi","tag-functions","tag-get-wmobj","tag-new-object","tag-powershell","tag-scripitnggames","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"My commentary for Beginner Event 5 in the 2011 Scripting Games is now available. One item that seems to be missing on the ScriptingGuys site is my complete solution so I thought I would share it here, plus a variation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-25T17:01:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-04-26T10:47:26+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Scripting Games 2011 Beginner Event 5 Commentary\",\"datePublished\":\"2011-04-25T17:01:25+00:00\",\"dateModified\":\"2011-04-26T10:47:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/\"},\"wordCount\":1077,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"functions\",\"Get-WMObj\",\"new-object\",\"PowerShell\",\"ScripitngGames\",\"WMI\"],\"articleSection\":[\"PowerShell\",\"PowerShell v2.0\",\"Scripting\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/\",\"name\":\"Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-04-25T17:01:25+00:00\",\"dateModified\":\"2011-04-26T10:47:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1369\\\/scripting-games-2001-beginner-event-5-commentary\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scripting Games 2011 Beginner Event 5 Commentary\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/","og_locale":"en_US","og_type":"article","og_title":"Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator","og_description":"My commentary for Beginner Event 5 in the 2011 Scripting Games is now available. One item that seems to be missing on the ScriptingGuys site is my complete solution so I thought I would share it here, plus a variation.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-04-25T17:01:25+00:00","article_modified_time":"2011-04-26T10:47:26+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Scripting Games 2011 Beginner Event 5 Commentary","datePublished":"2011-04-25T17:01:25+00:00","dateModified":"2011-04-26T10:47:26+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/"},"wordCount":1077,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["functions","Get-WMObj","new-object","PowerShell","ScripitngGames","WMI"],"articleSection":["PowerShell","PowerShell v2.0","Scripting","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/","name":"Scripting Games 2011 Beginner Event 5 Commentary &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-04-25T17:01:25+00:00","dateModified":"2011-04-26T10:47:26+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1369\/scripting-games-2001-beginner-event-5-commentary\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Scripting Games 2011 Beginner Event 5 Commentary"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1454,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1454\/teched-atlanta-managing-the-registry-with-powershell\/","url_meta":{"origin":1369,"position":0},"title":"TechEd Atlanta &#8211; Managing the Registry with PowerShell","author":"Jeffery Hicks","date":"May 23, 2011","format":false,"excerpt":"My second TechEd talk was about managing the registry with Windows PowerShell. If you were in the session you know that I stressed heavily using the PowerShell provider and cmdlets. For remote computers, leverage PowerShell's remoting infrastructure. But I also discussed using the \"raw\" .NET classes as well as WMI\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3615,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3615\/powershell-essentials-webinar\/","url_meta":{"origin":1369,"position":1},"title":"PowerShell Essentials Webinar","author":"Jeffery Hicks","date":"January 29, 2014","format":false,"excerpt":"Tomorrow I will be presenting a day of PowerShell training via a series of webinars for Windows IT Pro magazine. I will be presenting 3 webinars, each about 1 hour in length. The first webinar is on the PowerShell syntax and shell. Basically, how to survive in the shell if\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/windowsitpro.com\/site-files\/windowsitpro.com\/files\/imagecache\/product\/OnLine_icon_48.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":88,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/88\/powershell-parsing\/","url_meta":{"origin":1369,"position":2},"title":"Powershell Parsing","author":"Jeffery Hicks","date":"January 16, 2007","format":false,"excerpt":"In PowerShell, Get-WMIObject is a terrific cmdlet for remotely managing systems. If you have a text list of server or computer names, here's a quick method you could enumerate that list and do something to each server.foreach ($server in (Get-Content s:\\servers.txt)) {#skip blank lines if (($server).length -gt 0) { $server\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1977,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1977\/the-powershell-morning-report\/","url_meta":{"origin":1369,"position":3},"title":"The PowerShell Morning Report","author":"Jeffery Hicks","date":"January 10, 2012","format":false,"excerpt":"I love how easy it is to manage computers with Windows PowerShell. It is a great reporting tool, but often I find people getting locked into one approach. I'm a big believer in flexibility and re-use and using objects in the pipeline wherever I can. So I put together a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"Zazu","src":"https:\/\/i0.wp.com\/www.lionking.org\/imgarchive\/Clip_Art\/zazu03.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":37,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/37\/get-active-directory-user-information-in-powershell\/","url_meta":{"origin":1369,"position":4},"title":"Get Active Directory User Information in PowerShell","author":"Jeffery Hicks","date":"July 5, 2006","format":false,"excerpt":"One feature that PowerShell will likely be missing when it first ships is solid support for ADSI and working with Active Directory. You can use .NET DirectoryEntry objects but it feels more like programming and less like scripting. Another option for working with Active Directory in PowerShell is to use\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":170,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/170\/friendly-wmi-dates\/","url_meta":{"origin":1369,"position":5},"title":"Friendly WMI Dates","author":"Jeffery Hicks","date":"August 5, 2009","format":false,"excerpt":"Gee..you think you know something only to find out you don\u2019t. Or maybe this falls into the category of teaching an old dog new tricks. When I first started using PowerShell several years ago, I learned about how to convert a WMI date to a more user friendly format...","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1369"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1369\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}