{"id":3718,"date":"2014-02-24T12:14:48","date_gmt":"2014-02-24T17:14:48","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3718"},"modified":"2014-02-24T12:14:48","modified_gmt":"2014-02-24T17:14:48","slug":"theres-sum-thing-happening-here","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/","title":{"rendered":"There&#8217;s Sum-thing Happening Here"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-3719\" alt=\"calculator\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png\" width=\"144\" height=\"144\" \/><\/a>I am one of those IT Pros who keeps close tabs on system resources. I like to know what is being used and by what. As you might imagine, a cmdlet like Get-Process, is pretty useful to me. One of the things I'm always checking is how much memory Google Chrome is taking. I don't mean to pick on Chrome as I derive great benefit from it. But because I keep it open for days at a time I think system resources get a little carried away. So every once in a while I like to see how many Chrome processes are running and how much they are using.<\/p>\n<pre class=\"lang:batch decode:true\">PS C:\\&gt; get-process chrome\r\n\r\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName                   \r\n-------  ------    -----      ----- -----   ------     -- -----------                              \r\n    177      26    35564      35104   203     1.61   1976 chrome                                   \r\n    197      45    98676     107984   263    57.55   3016 chrome                                   \r\n    179      25    26872      20500   187     0.36   5956 chrome                                   \r\n    261      33    78456     103908   413   165.72   6260 chrome                                   \r\n    187      26    39656      39980   198    21.00   7744 chrome                                   \r\n    180      32    88896      85836   263    58.20   7828 chrome                                   \r\n   1610      92   119076     178436   492   286.77   8276 chrome                                   \r\n    192      38    87136      91124   257    13.98   9140 chrome                                   \r\n    193      39    73280      82288   245   122.19   9284 chrome                                   \r\n    194      27    57264      50276   204    15.20   9932 chrome                                   \r\n    201      32    22936      26780   264    34.91  10076 chrome<\/pre>\n<p>Now, what I really want is a total. I can get that for a single property easy enough using Measure-Object.<\/p>\n<pre class=\"lang:batch decode:true \" >PS C:\\&gt; get-process chrome | measure vm -sum\r\n\r\nCount    : 11\r\nAverage  :\r\nSum      : 3151364096\r\nMaximum  :\r\nMinimum  :\r\nProperty : VM\r\n\r\nPS C:\\&gt; (get-process chrome | measure vm -sum).sum\/1mb\r\n3000.12890625<\/pre>\n<p>But ideally I'd like to get totals for all of the properties I see with Get-Process. So I wrote an advanced PowerShell function called Get-ProcessTotal.<\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 3.0\r\n\r\n\r\nFunction Get-ProcessTotal {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nGet total values for multiple instances of same process\r\n\r\n.DESCRIPTION\r\nThis command is designed to get the total value of common process properties:\r\nHandles,NPM,PM,WS,VM, and CPU. The default behavior is to get the sum total\r\nof these properties for processes that might have multiple instances such as\r\nsvchost. Although you can also use a wildcard for the process name and get \r\ntotals for a group of processes.  As an alternative to the sum, you can get the\r\naverage of these properties.\r\n\r\nThe command writes a custom object to the pipeline and uses a custom format view\r\nso that the output looks like what you get with Get-Process. This command will \r\ncreate a format ps1xml file on-the-fly called ProcessTotal.Format.ps1xml and\r\nstore it in the windowsPowerShell folder under Documents. After the file has been\r\ncreated this command will simply load it into your PowerShell session.\r\n\r\nThe command writes a custom object that will include the total number of \r\nprocesses as well as a property that contains the original processes.\r\n\r\n.PARAMETER Name\r\nThe name of the process you want to measure. You can use a wildcard. See \r\nthe examples.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; get-processtotal chrome\r\n\r\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s) ProcessName                                   \r\n-------  ------    -----      ----- -----   ------ -----------                                   \r\n   4801     612  1120888    1282976  4444  2153.59 chrome    \r\n\r\n.EXAMPLE\r\nPS C:\\&gt; get-processtotal chrome -average | select *\r\n\r\n\r\nHandles      : 300\r\nNPM          : 39135\r\nPM           : 71778048\r\nWS           : 82160640\r\nVM           : 291475200\r\nCPU          : 134.6279296875\r\nProcessName  : chrome\r\nComputername : JH-WIN81-ENT\r\nTotal        : 16\r\nProcesses    : {System.Diagnostics.Process (chrome), System.Diagnostics.Process (chrome), \r\n               System.Diagnostics.Process (chrome), System.Diagnostics.Process (chrome)...}\r\nMeasure      : Average\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; get-processtotal vm* -comp chi-hvr2\r\n\r\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s) ProcessName                                   \r\n-------  ------    -----      ----- -----   ------ -----------                                   \r\n   3193     205   110904     166300   873        0 vm*     \r\n\r\nCPU values are not available for remote computers.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; invoke-command {mkdir $env:userprofile\\Documents\\WindowsPowerShell | out-null} -comp chi-hvr2\r\n\r\nPS C:\\&gt; invoke-command $(get-item Function:\\Get-ProcessTotal).Scriptblock -comp chi-hvr2 -arg VM*\r\n\r\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s) ProcessName             PSComputerName        \r\n-------  ------    -----      ----- -----   ------ -----------             --------------        \r\n   3198     206   111012     166352   874 10178.39 VM*                     chi-hvr2\r\n\r\nThe first command creates the WindowsPowerShell folder on the remote computer.\r\nThe second command invokes the Get-ProcessTotal command on the remote computer\r\nwhich creates the format ps1xml file also remotely. \r\n\r\n.NOTES\r\nLast Updated: 2\/21\/2014\r\nVersion     : 0.9\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide\r\n PowerShell Deep Dives \r\n Learn PowerShell 3 in a Month of Lunches \r\n Learn PowerShell Toolmaking in a Month of Lunches \r\n \r\n   ****************************************************************\r\n   * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n   * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n   * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n   * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n   ****************************************************************\r\n\r\n.LINK\r\nhttp:\/\/jdhitsolutions.com\/blog\/2014\/02\/theres-sum-thing-happening-here\r\n\r\n.LINK\r\nGet-Process\r\nMeasure-Object\r\n\r\n.INPUTS\r\nString\r\n\r\n.OUTPUTS\r\nCustom object\r\n#&gt;\r\n\r\n\r\n[cmdletbinding(DefaultParameterSetName=\"Sum\")]\r\nParam(\r\n[Parameter(Position=0, Mandatory=$True,\r\nHelpMessage = \"Enter the name of a process\")]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"processname\")]\r\n[string]$Name,\r\n\r\n[Parameter(ParameterSetName=\"Sum\")]\r\n[switch]$Sum,\r\n\r\n[Parameter(ParameterSetName=\"Average\")]\r\n[switch]$Average,\r\n\r\n[ValidateNotNullorEmpty()]\r\n[string]$Computername=$env:COMPUTERNAME\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"\r\n    Write-Verbose -Message \"Querying processes on $computername\"\r\n    if ($Average) {\r\n        $measure=\"Average\"\r\n    }\r\n    else {\r\n        $measure=\"Sum\"\r\n    }\r\n    Write-Verbose -Message \"Measuring the $measure\"\r\n    #update format data if not found\r\n    if (-Not (Get-FormatData -TypeName \"My.ProcessTotal\")) {\r\n      \r\n      $formatXML=Join-Path -path \"$env:USERPROFILE\\Documents\\WindowsPowerShell\" -ChildPath \"ProcessTotal.format.ps1xml\"\r\n      \r\n      #test if ps1xml file exists and if not create the file\r\n      if (-Not (Test-Path -path $formatXMl)) {\r\n      #the format xml. The Here string must be left justified to start and finish\r\n      $xml=@'\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n&lt;!-- *******************************************************************\r\nThis was copied from the DotNetType.format.ps1xml file and modified\r\nto fit my needs.\r\n******************************************************************** --&gt;\r\n&lt;Configuration&gt;\r\n    &lt;ViewDefinitions&gt;\r\n      &lt;View&gt;\r\n            &lt;Name&gt;process&lt;\/Name&gt;\r\n            &lt;ViewSelectedBy&gt;\r\n                &lt;TypeName&gt;My.ProcessTotal&lt;\/TypeName&gt;\r\n            &lt;\/ViewSelectedBy&gt;\r\n            &lt;TableControl&gt;\r\n                &lt;TableHeaders&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;Handles&lt;\/Label&gt;\r\n                        &lt;Width&gt;7&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;NPM(K)&lt;\/Label&gt;\r\n                        &lt;Width&gt;7&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;PM(K)&lt;\/Label&gt;\r\n                        &lt;Width&gt;8&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;WS(K)&lt;\/Label&gt;\r\n                        &lt;Width&gt;10&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;VM(M)&lt;\/Label&gt;\r\n                        &lt;Width&gt;5&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader&gt;\r\n                        &lt;Label&gt;CPU(s)&lt;\/Label&gt;\r\n                        &lt;Width&gt;8&lt;\/Width&gt;\r\n                        &lt;Alignment&gt;right&lt;\/Alignment&gt;\r\n                    &lt;\/TableColumnHeader&gt;\r\n                    &lt;TableColumnHeader \/&gt;\r\n                &lt;\/TableHeaders&gt;\r\n                &lt;TableRowEntries&gt;\r\n                    &lt;TableRowEntry&gt;\r\n                        &lt;TableColumnItems&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;[int]$_.Handles&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;[int]($_.NPM \/ 1024)&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;[int]($_.PM \/ 1024)&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;[int]($_.WS \/ 1024)&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;[int]($_.VM \/ 1048576)&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;ScriptBlock&gt;\r\nif ($_.CPU -ne $()) \r\n{ \r\n   [math]::Round($_.CPU,2)\r\n}\r\nelse {\r\n   \"NA\"\r\n}\r\n\t\t\t\t&lt;\/ScriptBlock&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                            &lt;TableColumnItem&gt;\r\n                                &lt;PropertyName&gt;ProcessName&lt;\/PropertyName&gt;\r\n                            &lt;\/TableColumnItem&gt;\r\n                        &lt;\/TableColumnItems&gt;\r\n                    &lt;\/TableRowEntry&gt;\r\n                &lt;\/TableRowEntries&gt;\r\n            &lt;\/TableControl&gt;\r\n        &lt;\/View&gt;\r\n    &lt;\/ViewDefinitions&gt;\r\n&lt;\/Configuration&gt;\r\n'@\r\n        Try {\r\n            $xml | Out-File -FilePath $formatXML -Encoding ascii -ErrorAction Stop\r\n           \r\n        }\r\n        Catch {\r\n            Write-Warning \"Failed to create format xml file $formatXML\"\r\n            Write-Warning $_.Exception.Message\r\n        } \r\n      } #if not test path for format xml file\r\n\r\n       #update format data\r\n       Write-Verbose -Message \"Adding a custom format view from $formatxml.\"\r\n       Update-FormatData -AppendPath $formatXML -ErrorAction Stop\r\n    } #if not get-formatdata\r\n\r\n    #define a hashtable of parameters to splat to Measure-Object so we \r\n    #can get either -Sum or -Average\r\n    $measureParams=@{$Measure=$True;Property=$Null}\r\n} #begin\r\n\r\nProcess {\r\n\r\nTry {\r\n    Write-Verbose -Message \"Getting processes for $Name\"\r\n    $processes = Get-Process $Name -Computername $computername -ErrorAction Stop\r\n}\r\nCatch {\r\n    Write-Warning \"Failed to find process $name on $computername\"\r\n    #bail out\r\n    Return\r\n}\r\n\r\nIf ($processes) {\r\n    Write-Verbose -message \"Defining a hash table of property values\"\r\n    $properties=\"Handles\",\"NPM\",\"PM\",\"WS\",\"VM\",\"CPU\"\r\n    #initialize the ordered hash table\r\n    $propertyHash=[ordered]@{}\r\n    #add each property to the hash table getting the sum or average\r\n    foreach ($property in $properties) {\r\n       Write-Verbose -message \"Adding $property\"\r\n       $measureParams.Property = $property\r\n       $value = $processes | Measure-Object @measureParams | Select -ExpandProperty $measure\r\n       $propertyHash.Add($property,$value)\r\n    } #foreach property\r\n\r\n    Write-Verbose -message \"Adding remaining properties\"\r\n    $propertyHash.Add(\"ProcessName\",$Name)\r\n    $propertyHash.Add(\"Computername\",$processes[0].MachineName)\r\n    $propertyHash.Add(\"Total\",$processes.count)\r\n    $propertyHash.Add(\"Processes\",$processes)\r\n    $propertyHash.Add(\"Measure\",$Measure)\r\n\r\n    #create a custom object\r\n    Write-Verbose -Message \"Creating object from hashtable\"\r\n    $obj = New-Object -TypeName psobject -Property $propertyHash \r\n\r\n    #add a type name\r\n    Write-Verbose -Message \"Adding type name\"\r\n    $obj.psobject.TypeNames[0]=\"My.ProcessTotal\"\r\n\r\n    #write the object to the pipeline\r\n    $obj\r\n\r\n} #if $processes\r\n} #process\r\n\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n} #end function\r\n\r\n#add an optional alias\r\nSet-Alias -Name gpt -Value Get-ProcessTotal<\/pre>\n<p>The main part of the function gets all instances of a process and then creates a custom object with a sum total for several properties.<\/p>\n<pre class=\"lang:ps decode:true \" >$properties=\"Handles\",\"NPM\",\"PM\",\"WS\",\"VM\",\"CPU\"\r\n    #initialize the ordered hash table\r\n    $propertyHash=[ordered]@{}\r\n    #add each property to the hash table getting the sum or average\r\n    foreach ($property in $properties) {\r\n       Write-Verbose -message \"Adding $property\"\r\n       $measureParams.Property = $property\r\n       $value = $processes | Measure-Object @measureParams | Select -ExpandProperty $measure\r\n       $propertyHash.Add($property,$value)\r\n    } #foreach property<\/pre>\n<p>The output also includes the computer name, in case you are querying a remote computer, the total count and also the original process objects in case you need to do something else with them.<\/p>\n<pre class=\"lang:ps decode:true \" >$propertyHash.Add(\"ProcessName\",$Name)\r\n    $propertyHash.Add(\"Computername\",$processes[0].MachineName)\r\n    $propertyHash.Add(\"Total\",$processes.count)\r\n    $propertyHash.Add(\"Processes\",$processes)\r\n    $propertyHash.Add(\"Measure\",$Measure)\r\n\r\n    #create a custom object\r\n    Write-Verbose -Message \"Creating object from hashtable\"\r\n    $obj = New-Object -TypeName psobject -Property $propertyHash<\/pre>\n<p>That could be sufficient, but all the values would be in bytes and the default display would be a list. Instead I wanted default output like I get with Get-Process. So I took advantage of PowerShell's extensible type system and created my own format data xml file. Actually what I did was to find the section in the DotNetTypes.format.ps1xml file for process objects, copied it and tweaked it. <\/p>\n<p>My original idea was to have a separate XML file. If I was building a module, that would be the best choice. But this was a single, stand-alone function so I added some logic to create the XML file on first use and add it to my PowerShell session. The XML content is stored as a Here string in the function.<\/p>\n<pre class=\"lang:ps decode:true \" >if (-Not (Get-FormatData -TypeName \"My.ProcessTotal\")) {\r\n      \r\n      $formatXML=Join-Path -path \"$env:USERPROFILE\\Documents\\WindowsPowerShell\" -ChildPath \"ProcessTotal.format.ps1xml\"\r\n      \r\n      #test if ps1xml file exists and if not create the file\r\n      if (-Not (Test-Path -path $formatXMl)) {\r\n      #the format xml. The Here string must be left justified to start and finish\r\n      $xml=@'\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n...\r\nTry {\r\n            $xml | Out-File -FilePath $formatXML -Encoding ascii -ErrorAction Stop\r\n           \r\n        }\r\n        Catch {\r\n            Write-Warning \"Failed to create format xml file $formatXML\"\r\n            Write-Warning $_.Exception.Message\r\n        } \r\n      } #if not test path for format xml file\r\n\r\n       #update format data\r\n       Write-Verbose -Message \"Adding a custom format view from $formatxml.\"\r\n       Update-FormatData -AppendPath $formatXML -ErrorAction Stop\r\n    } #if not get-formatdata<\/pre>\n<p>In short, the function first tests to see if there is format data for an object of type My.ProcessTotal. If not, in then tests for the XML file which I'm storing in the WindowsPowerShell folder. If it doesn't exist, the file is created. In any event once the file exists it is then loaded into PowerShell using Update-FormatData.<\/p>\n<p>How does PowerShell know what type to use? I told it. When I defined my custom object I also gave it a new type name.<\/p>\n<pre class=\"lang:ps decode:true \" >$obj.psobject.TypeNames[0]=\"My.ProcessTotal\"<\/pre>\n<p>Once the function is loaded into my session I can now get a result like this:<\/p>\n<pre class=\"lang:batch decode:true \" >PS C:\\&gt; Get-ProcessTotal chrome\r\n\r\nHandles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s) ProcessName\r\n-------  ------    -----      ----- -----   ------ -----------\r\n   3560     424   747336     855356  3027   948.83 chrome<\/pre>\n<p>The output is just like Get-Process except the values are sums. I also added an option to get an average instead just in case. If you pipe to Get-Member you'll see the new type definition, as well as the other non-default properties.<\/p>\n<pre class=\"lang:batch decode:true \" >PS C:\\&gt; Get-ProcessTotal chrome | get-member\r\n\r\n\r\n   TypeName: My.ProcessTotal\r\n\r\nName         MemberType   Definition\r\n----         ----------   ----------\r\nEquals       Method       bool Equals(System.Object obj)\r\nGetHashCode  Method       int GetHashCode()\r\nGetType      Method       type GetType()\r\nToString     Method       string ToString()\r\nComputername NoteProperty System.String Computername=JH-WIN81-ENT\r\nCPU          NoteProperty System.Double CPU=960.484375\r\nHandles      NoteProperty System.Double Handles=3569\r\nMeasure      NoteProperty System.String Measure=Sum\r\nNPM          NoteProperty System.Double NPM=435088\r\nPM           NoteProperty System.Double PM=762679296\r\nProcesses    NoteProperty System.Object[] Processes=System.Object[]\r\nProcessName  NoteProperty System.String ProcessName=chrome\r\nTotal        NoteProperty System.Int32 Total=11\r\nVM           NoteProperty System.Double VM=3170050048\r\nWS           NoteProperty System.Double WS=879349760<\/pre>\n<p>There are some other examples in the comment based help. The script also creates an alias so if you don't want it be sure to comment out the line at the end.<\/p>\n<p>I hope some of you will kick it around and let me know what you think. Or at the very least I hope you picked up a new technique or idea.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am one of those IT Pros who keeps close tabs on system resources. I like to know what is being used and by what. As you might imagine, a cmdlet like Get-Process, is pretty useful to me. One of the things I&#8217;m always checking is how much memory Google Chrome is taking. I don&#8217;t&#8230;<\/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":"There's Sum-thing Happening Here http:\/\/wp.me\/p1nF6U-XY #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[286,178,534,540,391],"class_list":["post-3718","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-get-process","tag-measure-object","tag-powershell","tag-scripting","tag-update-formatdata"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>There&#039;s Sum-thing Happening Here &#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\/3718\/theres-sum-thing-happening-here\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"There&#039;s Sum-thing Happening Here &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I am one of those IT Pros who keeps close tabs on system resources. I like to know what is being used and by what. As you might imagine, a cmdlet like Get-Process, is pretty useful to me. One of the things I&#039;m always checking is how much memory Google Chrome is taking. I don&#039;t...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-24T17:14:48+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png\" \/>\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=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"There&#8217;s Sum-thing Happening Here\",\"datePublished\":\"2014-02-24T17:14:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/\"},\"wordCount\":563,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/calculator.png\",\"keywords\":[\"Get-Process\",\"Measure-Object\",\"PowerShell\",\"Scripting\",\"Update-FormatData\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/\",\"name\":\"There's Sum-thing Happening Here &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/calculator.png\",\"datePublished\":\"2014-02-24T17:14:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#primaryimage\",\"url\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/calculator.png\",\"contentUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/02\\\/calculator.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3718\\\/theres-sum-thing-happening-here\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"There&#8217;s Sum-thing Happening Here\"}]},{\"@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":"There's Sum-thing Happening Here &#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\/3718\/theres-sum-thing-happening-here\/","og_locale":"en_US","og_type":"article","og_title":"There's Sum-thing Happening Here &#8226; The Lonely Administrator","og_description":"I am one of those IT Pros who keeps close tabs on system resources. I like to know what is being used and by what. As you might imagine, a cmdlet like Get-Process, is pretty useful to me. One of the things I'm always checking is how much memory Google Chrome is taking. I don't...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-02-24T17:14:48+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"There&#8217;s Sum-thing Happening Here","datePublished":"2014-02-24T17:14:48+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/"},"wordCount":563,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png","keywords":["Get-Process","Measure-Object","PowerShell","Scripting","Update-FormatData"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/","name":"There's Sum-thing Happening Here &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png","datePublished":"2014-02-24T17:14:48+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#primaryimage","url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png","contentUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/02\/calculator.png"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3718\/theres-sum-thing-happening-here\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"There&#8217;s Sum-thing Happening Here"}]},{"@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":2231,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/","url_meta":{"origin":3718,"position":0},"title":"Convert Boolean Values","author":"Jeffery Hicks","date":"April 24, 2012","format":false,"excerpt":"First, let me state right off the bat that what I have here should be for very special use cases and is NOT something I feel you need to be using at all. Now the use case: You are preparing a report of some sort for a non-technical user and\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3971,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3971\/tracking-your-day-with-powershell\/","url_meta":{"origin":3718,"position":1},"title":"Tracking Your Day with PowerShell","author":"Jeffery Hicks","date":"August 26, 2014","format":false,"excerpt":"Not too long ago, I received an email with a snippet of PowerShell code and a request for assistance. The code snippet used a little .NET code to retrieve the process for the currently active window. The goal was to have a PowerShell script run, keeping track of how long\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"timer","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/timer.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1431,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1431\/process-snapshot\/","url_meta":{"origin":3718,"position":2},"title":"Process Snapshot","author":"Jeffery Hicks","date":"May 11, 2011","format":false,"excerpt":"Yesterday I ended up running an impromptu browser test, comparing memory utilization. See what Twitter can do to your time!! The browsers themselves are really irrelevant. What you might find useful is the little PowerShell code I put together to periodically check and compare the browser processes. I decided to\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":1441,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1441\/get-process-detail\/","url_meta":{"origin":3718,"position":3},"title":"Get Process Detail","author":"Jeffery Hicks","date":"May 12, 2011","format":false,"excerpt":"The other day I posted a snippet of code that I as using to monitor process memory utilization for a few web browsers. I thought the information and technique were useful enough to modularize in the form of a function. Perhaps I want to check working set on a different\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":1640,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1640\/create-a-read-only-powershell-session\/","url_meta":{"origin":3718,"position":4},"title":"Create a Read-Only PowerShell Session","author":"Jeffery Hicks","date":"September 1, 2011","format":false,"excerpt":"In my PowerShell training class this week, I was demonstrating how to take advantage of the -Whatif and -Confirm parameters. These parameters exist (or should) for any cmdlet that changes the environment such as stopping a service, killing a process or copying a file. PS C:\\> get-process | kill -whatif\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":6336,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6336\/building-a-powershell-process-memory-tool\/","url_meta":{"origin":3718,"position":5},"title":"Building a PowerShell Process Memory Tool","author":"Jeffery Hicks","date":"December 28, 2018","format":false,"excerpt":"This week I've been testing out a new browser, Brave, as a possible replacement for Firefox. One of the reasons I switched to Firefox from Chrome was performance and better resource utilization. Brave may now be a better choice, but that's not what this article is about. In order to\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\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-20.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-20.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-20.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-20.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3718","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=3718"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3718\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}