{"id":5931,"date":"2018-04-02T09:32:42","date_gmt":"2018-04-02T13:32:42","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=5931"},"modified":"2021-04-09T14:54:18","modified_gmt":"2021-04-09T18:54:18","slug":"a-powershell-mystery","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/","title":{"rendered":"A PowerShell Mystery"},"content":{"rendered":"\n<p>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 when this command gave me an error:<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>But running <a title=\"read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=287299\" target=\"_blank\" rel=\"noopener\">Get-CimInstance<\/a> without the computer name worked just fine. I also had no problems using <a title=\"read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/p\/?linkid=290505\" target=\"_blank\" rel=\"noopener\">Get-WmiObject<\/a> connecting to the local host. Which is good because my first thought was a corrupt CIM repository. But it turned out to be something else that we normally don't think about, because usually it just works.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Since Get-WmiObject worked and Get-CimInstance worked with out a remote connection, I was pretty sure my WMI setup was ok. I also had no issues querying anything else, even with a remote connection back to the local host. That left WSMan as a suspect. When you query WMI using the CIM cmdlets and make a remote connection, even if the \"remote\" computer is the local host,&nbsp; PowerShell creates a WSMan connection. So my first step was to gather a bit more information.<\/p>\n\n\n\n<p>I opened up Event Viewer and enabled the Analytic log under Applications and Services Logs\\Microsoft\\Windows\\Windows Remote Management. Don't forget to disable it when you are done troubleshooting.<\/p>\n\n\n\n<p>Then I re-ran my command.<\/p>\n\n\n\n<pre class=\"wp-block-code lang:ps mark:0 decode:true\"><code lang=\"powershell\" class=\"language-powershell\">Get-CimInstance Win32_ComputerSystem -ComputerName $env:Computername\n<\/code><\/pre>\n\n\n\n<p>Now to the logs. I stepped through the events and saw the network setup as well as the authentication process. Eventually I see the beginning of the WMI enumeration.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-1.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-1.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>After scrolling through a few more events I encountered this error:<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-2.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-2.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>Interesting. WMI wants to send almost 3MB of data back in response. WSMan doesn't like that as confirmed in the next event.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-3.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-3.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>And eventually I get my invalid XML error. This all makes sense because when you use WSMan, the result is serialized as XML and transmitted back to you. In my scenario, I believe PowerShell received part of the response, but then the process is aborted so the XML is never completed and thus becomes invalid.<\/p>\n\n\n\n<p>To finally verify WSMan was the culprit I tried using the command line winrm utility.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-4.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-4.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>Clearly my WSMan configuration was failing me so I checked my settings in the WSMan PSDrive.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-5.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-5.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>The MaxEnvelopeSizeKB was the likely culprit so I raised it.<\/p>\n\n\n\n<pre class=\"wp-block-code lang:ps mark:0 decode:true\"><code lang=\"powershell\" class=\"language-powershell\">Set-Item -Path WSMan:\\localhost\\maxEnvelopeSizeKB -Value 5000\n<\/code><\/pre>\n\n\n\n<p>Now re-running my Get-CimInstance expression worked as expected.<\/p>\n\n\n\n<p>At this point I should have been satisfied, but I wondered why I get was getting so much data for this class. I re-tried my winrm enum command and while it didn't immediately give me an error, it also didn't immediately give me a response. Eventually the command completed and by the time I checked the window again it was full of byte values. Fortunately I was able to scroll up and see that the OEMLogoBitmap property was responsible. Interesting.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-6.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-6.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>I reset my MaxEnvelopeSizeKB back to the default value of 500 and tried a more selective query using Get-CimInstance.<\/p>\n\n\n\n<pre class=\"wp-block-code lang:ps mark:0 decode:true\"><code lang=\"powershell\" class=\"language-powershell\">Get-CimInstance Win32_ComputerSystem -ComputerName $env:Computername -Property Name,Model,TotalPhysicalMemory\n<\/code><\/pre>\n\n\n\n<p>That worked as expected. But when I tried getting just the OEMLogoBitmap property I got the same error. Resetting WSMan so I could get all the data, I measured the size of the array and found that it was only 43KB. Serialization must add some overhead. In fact I tried simulating the process.<\/p>\n\n\n\n<pre class=\"wp-block-code lang:ps mark:0 decode:true\"><code lang=\"powershell\" class=\"language-powershell\">$r = Get-CimInstance win32_computersystem -ComputerName $env:Computername\n[xml]$logo = $r.OEMLogoBitmap | convertto-xml\n$logo.save(\"c:\\work\\logo.xml\")\n<\/code><\/pre>\n\n\n\n<p>I'm sure there's a bit more than this. Still I ended up with a file that was 1.8MB in size which is a problem when the default limit is 500KB.<\/p>\n\n\n\n<p>So where does this leave me? For now, there's no issue with me leaving my MaxEnvelopeSizeKB at a higher setting. I don't consider any of this a bug. Nor do I put any blame on the vendor who decided to populate the WMI property. That's why it is there. It only causes an issue when querying the class&nbsp; over WSMan. When using a DCOM connection everything just works. I should point out, that even with the lower default, if I were more selective I would have had no problems.<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image-7.png\"><img decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb-7.png\" alt=\"image\" title=\"image\"\/><\/a><\/figure>\n\n\n\n<p>But like many of you I'm probably a bit too lazy. Even though limiting your WMI queries to just the properties you need is definitely a recommended best practice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 when this command gave me&#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":"New on the blog: A #PowerShell Mystery","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,19],"tags":[387,534,89],"class_list":["post-5931","post","type-post","status-publish","format-standard","hentry","category-powershell","category-wmi","tag-cim","tag-powershell","tag-wsman"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A PowerShell Mystery &#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\/5931\/a-powershell-mystery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A PowerShell Mystery &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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 when this command gave me...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-02T13:32:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-09T18:54:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.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=\"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\\\/5931\\\/a-powershell-mystery\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"A PowerShell Mystery\",\"datePublished\":\"2018-04-02T13:32:42+00:00\",\"dateModified\":\"2021-04-09T18:54:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/\"},\"wordCount\":707,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/image_thumb.png\",\"keywords\":[\"CIM\",\"PowerShell\",\"wsman\"],\"articleSection\":[\"PowerShell\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/\",\"name\":\"A PowerShell Mystery &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/image_thumb.png\",\"datePublished\":\"2018-04-02T13:32:42+00:00\",\"dateModified\":\"2021-04-09T18:54:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/image_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/image_thumb.png\",\"width\":1028,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5931\\\/a-powershell-mystery\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A PowerShell Mystery\"}]},{\"@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":"A PowerShell Mystery &#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\/5931\/a-powershell-mystery\/","og_locale":"en_US","og_type":"article","og_title":"A PowerShell Mystery &#8226; The Lonely Administrator","og_description":"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 when this command gave me...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/","og_site_name":"The Lonely Administrator","article_published_time":"2018-04-02T13:32:42+00:00","article_modified_time":"2021-04-09T18:54:18+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"A PowerShell Mystery","datePublished":"2018-04-02T13:32:42+00:00","dateModified":"2021-04-09T18:54:18+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/"},"wordCount":707,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.png","keywords":["CIM","PowerShell","wsman"],"articleSection":["PowerShell","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/","name":"A PowerShell Mystery &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.png","datePublished":"2018-04-02T13:32:42+00:00","dateModified":"2021-04-09T18:54:18+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/04\/image_thumb.png","width":1028,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5931\/a-powershell-mystery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"A PowerShell Mystery"}]},{"@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":5864,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5864\/a-powershell-dns-suffix-tool\/","url_meta":{"origin":5931,"position":0},"title":"A PowerShell DNS Suffix Tool","author":"Jeffery Hicks","date":"February 1, 2018","format":false,"excerpt":"The other day my good friend Greg Shields asked for a little assistance with a PowerShell problem. He was trying to use PowerShell to set the primary DNS suffix for a computer. This\u00a0 is different than the DNS suffix you can set on a network adapter configuration. Instead, he was\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\/02\/system1_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":912,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/912\/powershell-is-not-ominipotent\/","url_meta":{"origin":5931,"position":1},"title":"PowerShell Is Not Omnipotent","author":"Jeffery Hicks","date":"September 7, 2010","format":false,"excerpt":"Last week I was working on a problem in a PowerShell forum. The admin was having problems getting Add-Computer to work. After a bit of \"try this\/try that\" something became clear, and it's something that is easy to overlook. Especially when we get lulled into thinking PowerShell is omnipotent. Now,\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":5931,"position":2},"title":"PowerShell 7 Scripting with the PowerShell ISE","author":"Jeffery Hicks","date":"May 11, 2020","format":false,"excerpt":"By now, everyone should have gotten the memo that with the move to PowerShell 7, the PowerShell ISE should be considered deprecated. When it comes to PowerShell script and module development for PowerShell 7, the recommended tool is Visual Studio Code. It is free and offers so much more than\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\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":88,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/88\/powershell-parsing\/","url_meta":{"origin":5931,"position":3},"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":148,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/148\/order-managing-active-directory-with-windows-powershell-tfm-finally\/","url_meta":{"origin":5931,"position":4},"title":"Order Managing Active Directory with Windows PowerShell: TFM &#8211; Finally!","author":"Jeffery Hicks","date":"September 22, 2008","format":false,"excerpt":"Yes, its finally true. You can finally get your hands on Managing Active Directory with Windows PowerShell: TFM. The book is being printed so you can get your copy today. You can order it today at ScriptingOutpost.com in both print and ebook format. Or if you prefer the best of\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":1687,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1687\/filter-left\/","url_meta":{"origin":5931,"position":5},"title":"Filter Left","author":"Jeffery Hicks","date":"October 14, 2011","format":false,"excerpt":"When writing WMI queries expressions in Windows PowerShell, it is recommended to use WMI filtering, as opposed to getting objects and then filtering with Where-Object. I see expressions like this quite often: [cc lang=\"PowerShell\"] get-wmiobject win32_process -computer $c | where {$_.name -eq \"notepad.exe\"} [\/cc] In this situation, ALL process objects\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5931","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=5931"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5931\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}