{"id":3105,"date":"2013-06-13T14:46:10","date_gmt":"2013-06-13T18:46:10","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3105"},"modified":"2013-06-13T14:46:10","modified_gmt":"2013-06-13T18:46:10","slug":"adding-system-path-to-ciminstance-objects","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/","title":{"rendered":"Adding System Path to CIMInstance Objects"},"content":{"rendered":"<p>The other night when I <a title=\"Turning CLI Tools into PowerShell Tools\" href=\"http:\/\/jdhitsolutions.com\/blog\/2013\/06\/turning-cli-tools-into-powershell-tools\/\" target=\"_blank\">presented <\/a>for the Mississippi PowerShell Users' Group, one of the members showed some PowerShell 3.0 code using the CIM cmdlets. At issue is how the CIM cmdlets handle the WMI system properties like __SERVER and __RELPATH. By default, those properties aren't displayed, but they are captured in the CimSystemProperties property.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3106\" alt=\"gcim-systemproperties\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.png\" width=\"625\" height=\"220\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-300x106.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-624x221.png 624w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>The problem is that the __PATH property is not captured when using Get-CIMInstance as you can see in the screen shot. This is apparently a known issue. Using Get-WMIObject still works.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; get-wmiobject win32_service -filter \"name='bits'\" | Select -expand __PATH\r\n\\\\SERENITY\\root\\cimv2:Win32_Service.Name=\"BITS\"<\/pre>\n<p>Most of the time this probably isn't a big deal. But perhaps there are situations where you need the __PATH property. I saw some code the other night that constructed the __PATH property. I was intrigued and decided to figure this out for myself. The path needs the computer name, the namespace-class path, the name of the class, the class key and the value of that key. I have most of this already from the<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; $c.CimSystemProperties.ServerName\r\nSERENITY\r\nPS C:\\&gt; $c.CimSystemProperties.Namespace.Replace(\"\/\",\"\\\")\r\nroot\\cimv2\r\nPS C:\\&gt; $c.CimSystemProperties.ClassName\r\nWin32_Service<\/pre>\n<p>I switched the direction of the slash in the namespace. The only part I'm missing is the key property. But I can find it by looking at the qualifiers for the class properties. Think of a qualifier as a tag to denotes a special use. What is really cool about the CIMInstance, is that class information is included. This means I can look at the class from the object itself.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; $c.cimclass.CimClassProperties | select name,qualifiers<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3108\" alt=\"get-ciminstance-classproperties\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties-1024x606.png\" width=\"625\" height=\"369\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties-1024x606.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties-300x177.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties-624x369.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/get-ciminstance-classproperties.png 1137w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>All I need to do is find the property with a KEY qualifier.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; $c.cimclass.CimClassProperties | where {$_.qualifiers.name -contains 'key'}\r\n\r\nName               : Name\r\nValue              :\r\nCimType            : String\r\nFlags              : Property, Key, ReadOnly, NullValue\r\nQualifiers         : {read, key}\r\nReferenceClassName :<\/pre>\n<p>Now that I know the Name property is the key, I can finish building my path.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; $Key = $c[0].CimClass.CimClassProperties |\r\n&gt;&gt; where {$_.qualifiers.name -contains \"key\"} |\r\n&gt;&gt; select -ExpandProperty Name\r\n&gt;&gt;\r\nPS C:\\&gt; $c | Select @{Name=\"__PATH\";Expression={\r\n&gt;&gt;   '\\\\{0}\\{1}:{2}{3}' -f $_.CimSystemProperties.ServerName,\r\n&gt;&gt;   $_.CimSystemProperties.Namespace.Replace(\"\/\",\"\\\"),\r\n&gt;&gt;   $_.CimSystemProperties.ClassName,\r\n&gt;&gt;   \".$($key)=\"\"$($_.$key)\"\"\"\r\n&gt;&gt;   }}\r\n&gt;&gt;\r\n\r\n__PATH\r\n------\r\n\\\\SERENITY\\root\\cimv2:Win32_Service.Name=\"BITS\"<\/pre>\n<p>And this is the exact path I would get using Get-WMIObject.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; Get-WmiObject win32_service -filter \"name='bits'\" | select __Path\r\n\r\n__PATH\r\n------\r\n\\\\SERENITY\\root\\cimv2:Win32_Service.Name=\"BITS\"<\/pre>\n<p>Of course, I don't want to have to do all that typing so I created a function to do the work for me.<\/p>\n<pre class=\"lang:ps decode:true\">#requires -version 3.0\r\n\r\nFunction Add-CIMPath {\r\n&lt;#\r\n.Synopsis\r\nAdd the __PATH property to a CIMInstance object\r\n.Description\r\nThe Get-CIMInstance cmdlet by default doesn't display the WMI system properties\r\nlike __SERVER. The properties are available in the CimSystemProperties property\r\nexcept for __PATH. This function will construct the __PATH property and add it\r\nto a CIMInstance object.\r\n.Example\r\nPS C:\\&gt; get-ciminstance win32_memorydevice | add-cimpath | select __Path\r\n\r\n__PATH\r\n------\r\n\\\\SERVER01\\root\\cimv2:Win32_MemoryDevice.DeviceID=\"Memory Device 0\"\r\n\\\\SERVER01\\root\\cimv2:Win32_MemoryDevice.DeviceID=\"Memory Device 1\"\r\n.Example\r\nPS C:\\&gt; get-ciminstance win32_bios -computer netbk8 | add-cimpath | format-list __Path,PSComputername\r\n\r\n__PATH         : \\\\NETBK8\\root\\cimv2:Win32_BIOS.Name=\"Rev 1.0\r\n                 \",SoftwareElementID=\"Rev 1.0\r\n                 \",SoftwareElementState=\"3\",TargetOperatingSystem=\"0\",Version=\"LENOVO - 6040000\"\r\nPSComputerName : netbk8\r\n.Inputs\r\nCIMInstance\r\n.Outputs\r\nCIMInstance\r\n.Link\r\nGet-CIMInstance\r\n#&gt;\r\n\r\n[cmdletbinding()]\r\nParam (\r\n[Parameter(Position=0,ValueFromPipeline=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[ciminstance]$Inputobject\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n} #begin\r\n\r\nProcess {\r\n#get the key class property\r\nWrite-Verbose \"Processing $($Inputobject.CimClass.CimClassName)\"\r\n\r\n$Key = $Inputobject.CimClass.CimClassProperties | \r\nwhere {$_.qualifiers.name -contains \"key\"} | \r\nselect -ExpandProperty Name\r\n\r\nWrite-Verbose \"Creating __PATH Using key property $key\"\r\n\r\n$Inputobject | Add-Member -PassThru -MemberType NoteProperty -Name __PATH -Value ( \r\n '\\\\{0}\\{1}:{2}{3}' -f $_.CimSystemProperties.ServerName.ToUpper(),\r\n  $_.CimSystemProperties.Namespace.Replace(\"\/\",\"\\\"),\r\n  $_.CimSystemProperties.ClassName,\r\n  $(\r\n   if ($key -is [array]) {\r\n     #create a string with the array of key names and values\r\n     [string]$s = \".$($key[0])=\"\"$($_.($key[0]))\"\"\"\r\n     #add each additional key separated by comma\r\n     for ($i=1;$i -lt $key.count;$i++) {\r\n       $s+= \",$($key[$i])=\"\"$($_.($key[$i]))\"\"\"\r\n     }\r\n     $s\r\n   }\r\n   elseif ($Key) {\r\n    #just a single key\r\n    \".$($key)=\"\"$($_.$key)\"\"\"\r\n   }\r\n   else {\r\n    #no key\r\n    '=@'\r\n   })\r\n ) #value\r\n} #process\r\n\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end Add-CIMPath<\/pre>\n<p>The main part of the function is essentially what I just demonstrated. However, there are some special cases where there is no key property or there are multiple keys, so I had to add some logic to take that into account. I wrote the function assuming you would pipe a CIMInstance object to it and you want to add __PATH.<\/p>\n<pre class=\"lang:ps decode:true\">PS C:\\&gt; get-ciminstance win32_logicaldisk | Add-CIMPath | select __Path\r\n\r\n__PATH\r\n------\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"C:\"\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"D:\"\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"E:\"\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"F:\"\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"G:\"\r\n\\\\SERENITY\\root\\cimv2:Win32_LogicalDisk.DeviceID=\"Z:\"<\/pre>\n<p>And here is what the special cases look like.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath-1024x606.png\" alt=\"ciminstance-addpath\" width=\"625\" height=\"369\" class=\"aligncenter size-large wp-image-3109\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath-1024x606.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath-300x177.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath-624x369.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/ciminstance-addpath.png 1137w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>I'll be the first to admit this is a bit of a brute force hack and I can't guarantee I've covered every oddball use case. So if you try this and come across a class that doesn't give the correct __PATH, I hope you'll let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other night when I presented for the Mississippi PowerShell Users&#8217; Group, one of the members showed some PowerShell 3.0 code using the CIM cmdlets. At issue is how the CIM cmdlets handle the WMI system properties like __SERVER and __RELPATH. By default, those properties aren&#8217;t displayed, but they are captured in the CimSystemProperties property&#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":"Adding System Path to CIMInstance Objects in #PowerShell 3.0","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":[359,19],"tags":[388,534,540,547],"class_list":["post-3105","post","type-post","status-publish","format-standard","hentry","category-powershell-3-0","category-wmi","tag-get-ciminstance","tag-powershell","tag-scripting","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Adding System Path to CIMInstance Objects &#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\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding System Path to CIMInstance Objects &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"The other night when I presented for the Mississippi PowerShell Users&#039; Group, one of the members showed some PowerShell 3.0 code using the CIM cmdlets. At issue is how the CIM cmdlets handle the WMI system properties like __SERVER and __RELPATH. By default, those properties aren&#039;t displayed, but they are captured in the CimSystemProperties property....\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-06-13T18:46:10+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Adding System Path to CIMInstance Objects\",\"datePublished\":\"2013-06-13T18:46:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/\"},\"wordCount\":424,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/06\\\/gcim-systemproperties-1024x362.png\",\"keywords\":[\"Get-CIMInstance\",\"PowerShell\",\"Scripting\",\"WMI\"],\"articleSection\":[\"Powershell 3.0\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/\",\"name\":\"Adding System Path to CIMInstance Objects &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/06\\\/gcim-systemproperties-1024x362.png\",\"datePublished\":\"2013-06-13T18:46:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/06\\\/gcim-systemproperties.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/06\\\/gcim-systemproperties.png\",\"width\":1137,\"height\":403},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wmi\\\/3105\\\/adding-system-path-to-ciminstance-objects\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Powershell 3.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-3-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding System Path to CIMInstance Objects\"}]},{\"@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":"Adding System Path to CIMInstance Objects &#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\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/","og_locale":"en_US","og_type":"article","og_title":"Adding System Path to CIMInstance Objects &#8226; The Lonely Administrator","og_description":"The other night when I presented for the Mississippi PowerShell Users' Group, one of the members showed some PowerShell 3.0 code using the CIM cmdlets. At issue is how the CIM cmdlets handle the WMI system properties like __SERVER and __RELPATH. By default, those properties aren't displayed, but they are captured in the CimSystemProperties property....","og_url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-06-13T18:46:10+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Adding System Path to CIMInstance Objects","datePublished":"2013-06-13T18:46:10+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/"},"wordCount":424,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.png","keywords":["Get-CIMInstance","PowerShell","Scripting","WMI"],"articleSection":["Powershell 3.0","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/","url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/","name":"Adding System Path to CIMInstance Objects &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties-1024x362.png","datePublished":"2013-06-13T18:46:10+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/06\/gcim-systemproperties.png","width":1137,"height":403},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/wmi\/3105\/adding-system-path-to-ciminstance-objects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Powershell 3.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},{"@type":"ListItem","position":2,"name":"Adding System Path to CIMInstance Objects"}]},{"@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":8541,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8541\/getting-ciminstance-by-path\/","url_meta":{"origin":3105,"position":0},"title":"Getting CIMInstance by Path","author":"Jeffery Hicks","date":"August 20, 2021","format":false,"excerpt":"I am a member of the PowerShell Cmdlet Working Group. We've been looking into this issue and it is an intriguing one. Enough so that I spent some time looking into it and writing up some test code. If you work with WMI\/CIM this might be of interest to you.\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\/2021\/08\/add-ciminstancepath2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2342,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2342\/query-local-administrators-with-cim\/","url_meta":{"origin":3105,"position":1},"title":"Query Local Administrators with CIM","author":"Jeffery Hicks","date":"May 24, 2012","format":false,"excerpt":"Yesterday I posted an article on listing members of the local administrators group with PowerShell and Get-WmiObject. PowerShell 3.0 offers an additional way using the CIM cmdlets. The CIM cmdlets query the same WMI information, except instead of using the traditional RPC\/DCOM connection, these cmdlets utilize PowerShell's remoting endpoint so\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5931,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/","url_meta":{"origin":3105,"position":2},"title":"A PowerShell Mystery","author":"Jeffery Hicks","date":"April 2, 2018","format":false,"excerpt":"The other day I was prepping for my sessions at the upcoming PowerShell + DevOps Global Summit. As I usually do, when I am building demos that will connect to remote machines I often use the local computer as a placeholder. This should always work right? so imagine my surprise\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":2935,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2935\/get-ciminstance-from-powershell-2-0\/","url_meta":{"origin":3105,"position":3},"title":"Get CIMInstance from PowerShell 2.0","author":"Jeffery Hicks","date":"April 10, 2013","format":false,"excerpt":"I love the new CIM cmdlets in PowerShell 3.0. Querying WMI is a little faster because the CIM cmdlets query WMI using the WSMAN protocol instead of DCOM. The catch is that remote computers must be running PowerShell 3 which includes the latest version of the WSMAN protocol and the\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"get-ciminstance-error","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-ciminstance-error-300x145.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3661,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3661\/creating-cim-scripts-without-scripting\/","url_meta":{"origin":3105,"position":4},"title":"Creating CIM Scripts without Scripting","author":"Jeffery Hicks","date":"January 29, 2014","format":false,"excerpt":"When Windows 8 and Windows Server 2012 came out, along with PowerShell 3.0, we got our hands on some terrific technology in the form of the CIM cmdlets. Actually, we got much more than people realize. One of the reasons there was a big bump in the number of shipping\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":3497,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3497\/resolving-sids-with-wmi-wsman-and-powershell\/","url_meta":{"origin":3105,"position":5},"title":"Resolving SIDs with WMI, WSMAN and PowerShell","author":"Jeffery Hicks","date":"October 15, 2013","format":false,"excerpt":"In the world of Windows, an account SID can be a very enigmatic thing. Who is S-1-5-21-2250542124-3280448597-2353175939-1019? Fortunately, many applications, such as the event log viewer resolve the SID to an account name. The downside, is that when you are accessing that same type of information from PowerShell, you end\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"win32_sid-fail","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3105","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=3105"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3105\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}