{"id":3025,"date":"2013-05-14T10:39:09","date_gmt":"2013-05-14T14:39:09","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3025"},"modified":"2013-05-14T10:39:09","modified_gmt":"2013-05-14T14:39:09","slug":"scrub-up-powershell-content","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/","title":{"rendered":"Scrub Up PowerShell Content"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-3026\" alt=\"scrubbrush\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg\" width=\"300\" height=\"214\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush.jpg 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There's nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique to your company. Getting data out of these text files is very easy in PowerShell using Get-Content.<\/p>\n<pre class=\"lang:ps decode:true\">get-content c:\\work\\computers.txt<\/pre>\n<p>The potential problem is that the text file may not be perfectly formatted. Your text file might have blank lines. Or your computername may have a trailing white space. These things can complicate using the text file in a PowerShell pipelined expression. One approach is to filter the content using Where-Object and simply look for the existing of something.<\/p>\n<pre class=\"lang:ps decode:true\">get-content c:\\work\\computers.txt | where {$_} | &lt;something else&gt;<\/pre>\n<p>This works fine in filtering out blank lines. But won't fail if you have a line where someone inserted a tab or hit the space bar a few times. So let's take this a bit further and use a regular expression to filter out anything that doesn't have a non-whitespace character.<\/p>\n<pre class=\"lang:ps decode:true\">get-content c:\\work\\computers.txt | where {$_ -match \"\\w+\"} | &lt;something else&gt;<\/pre>\n<p>This should get rid of any lines that are nothing but tabs or spaces. Of course, there is still the issue of leading or trailing spaces. But we can handle that by using the string object's Trim() method.<\/p>\n<p>This is starting to get complicated. So I wrote a filtering function to scrub up content presumably from text files.<\/p>\n<pre class=\"lang:ps decode:true\">#requires -version 2.0\r\n\r\nFilter Scrub {\r\n&lt;#\r\n.Synopsis\r\nClean input strings\r\n.Description\r\nThis command is designed to take string input and scrub the data, filtering\r\nout blank lines and removing leading and trailing spaces. The default behavior\r\nis to write the object to the pipeline, however you can use -PropertyName to\r\nadd a property name value. If you use this parameter, the assumption is that\r\ncontents of the text file are a single item like a computer name.\r\n.Example\r\nPS C:\\&gt; get-content c:\\work\\computers.txt | scrub | foreach { get-wmiobject win32_operatingsystem -comp $_}\r\n.Example\r\nPS C:\\&gt; get-content c:\\work\\computers.txt | scrub -PropertyName computername | test-connection \r\n#&gt;\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,ValueFromPipeline=$True)]\r\n[string[]]$InputObject,\r\n[string]$PropertyName\r\n)\r\n\r\n  #filter out blank lines\r\n  $InputObject | where {$_ -match \"\\w+\"} | \r\n  ForEach-Object { \r\n    #trim off trailing and leading spaces\r\n    $clean = $_.Trim()\r\n    if ($PropertyName) {\r\n        #create a customobject property\r\n        New-Object -TypeName PSObject -Property @{$PropertyName=$clean}\r\n    }\r\n    else {\r\n        #write the clean object to the pipeline\r\n        $clean\r\n    }\r\n    } #foreach \r\n\r\n} #close Scrub<\/pre>\n<p>We don't use the Filter keyword much anymore but it seemed appropriate because that is the only thing Scrub is doing. In fact, I intentionally did not use a traditional verb-noun name. Technically this an advanced function this is just a Process script block. I wrote it with the assumption that you would pipe strings from Get-Content.<\/p>\n<p>Each processed string is filtered to get rid of blanks and spaces. Then each string is trimmed of leading and trailing spaces and finally written to the pipeline. Now I can run a command line this:<\/p>\n<pre class=\"lang:ps decode:true\">get-content c:\\scripts\\computers.txt | scrub<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3027\" alt=\"scrubexample1\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1-300x106.png\" width=\"300\" height=\"106\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1-300x106.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1-1024x362.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1-624x221.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample1.png 1137w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In my initial versions this solved all of my potential problems with text files. But then I realize I had an opportunity to add one more scrubbing feature. Many cmdlets have parameters that take pipeline input by property name. But strings from text files lack a property name. So I added a parameter to my Scrub filter to add a property name.<\/p>\n<pre class=\"lang:ps decode:true\">get-content c:\\scripts\\computers.txt | scrub -PropertyName Computername<\/pre>\n<p>Now I'm writing an object to the pipeline and can take advantage of pipeline binding.<\/p>\n<pre class=\"lang:ps decode:true \" >get-content c:\\scripts\\computers.txt | scrub -PropertyName Computername | test-connection -Count 1 <\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3028\" alt=\"scrubexample2\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2-300x130.png\" width=\"300\" height=\"130\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2-300x130.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2-1024x444.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2-624x270.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubexample2.png 1137w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I don't know about you, but this will come in very handy. I hope you'll let me know what you think.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There&#8217;s nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique&#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 blog post: Scrub Up #PowerShell Content","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":[426,534,540],"class_list":["post-3025","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-filter","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scrub Up PowerShell Content &#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\/3025\/scrub-up-powershell-content\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scrub Up PowerShell Content &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There&#039;s nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-14T14:39:09+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Scrub Up PowerShell Content\",\"datePublished\":\"2013-05-14T14:39:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/\"},\"wordCount\":444,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/05\\\/scrubbrush-300x214.jpg\",\"keywords\":[\"Filter\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/\",\"name\":\"Scrub Up PowerShell Content &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/05\\\/scrubbrush-300x214.jpg\",\"datePublished\":\"2013-05-14T14:39:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/05\\\/scrubbrush.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/05\\\/scrubbrush.jpg\",\"width\":600,\"height\":428},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3025\\\/scrub-up-powershell-content\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scrub Up PowerShell Content\"}]},{\"@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":"Scrub Up PowerShell Content &#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\/3025\/scrub-up-powershell-content\/","og_locale":"en_US","og_type":"article","og_title":"Scrub Up PowerShell Content &#8226; The Lonely Administrator","og_description":"It is probably a safe bet to say that IT Pros store a lot of information in simple text files. There's nothing with this. Notepad is ubiquitous and text files obviously easy to use. I bet you have text files of computer names, user names, service names, directories and probably a few that are unique...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-05-14T14:39:09+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg","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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Scrub Up PowerShell Content","datePublished":"2013-05-14T14:39:09+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/"},"wordCount":444,"commentCount":5,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg","keywords":["Filter","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/","name":"Scrub Up PowerShell Content &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush-300x214.jpg","datePublished":"2013-05-14T14:39:09+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/scrubbrush.jpg","width":600,"height":428},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3025\/scrub-up-powershell-content\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Scrub Up PowerShell Content"}]},{"@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":7549,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7549\/building-a-powershell-inventory\/","url_meta":{"origin":3025,"position":0},"title":"Building a PowerShell Inventory","author":"Jeffery Hicks","date":"June 16, 2020","format":false,"excerpt":"A few weeks ago, a new Iron Scripter PowerShell scripting challenge was issued. For this challenge we were asked to write some PowerShell code that we could use to inventory our PowerShell script library.\u00a0 Here's how I approached the problem, which by no means is the only way. Lines of\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\/06\/ast-results.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/ast-results.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/ast-results.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4000,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4000\/using-optimized-text-files-in-powershell\/","url_meta":{"origin":3025,"position":1},"title":"Using Optimized Text Files in PowerShell","author":"Jeffery Hicks","date":"September 8, 2014","format":false,"excerpt":"If you are like many IT Pros that I know, you often rely on text files in your PowerShell work. How many times have you used a text file of computernames with Get-Content and then piped to other PowerShell commands only to have errors. Text files are convenient, but often\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"document","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":88,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/88\/powershell-parsing\/","url_meta":{"origin":3025,"position":2},"title":"Powershell Parsing","author":"Jeffery Hicks","date":"January 16, 2007","format":false,"excerpt":"In PowerShell, Get-WMIObject is a terrific cmdlet for remotely managing systems. If you have a text list of server or computer names, here's a quick method you could enumerate that list and do something to each server.foreach ($server in (Get-Content s:\\servers.txt)) {#skip blank lines if (($server).length -gt 0) { $server\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4510,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/4510\/what-were-you-working-on\/","url_meta":{"origin":3025,"position":3},"title":"What Were You Working On?","author":"Jeffery Hicks","date":"August 21, 2015","format":false,"excerpt":"It probably comes as no surprise that I write a lot of PowerShell code. Like you, I'm usually working on several projects at the same time, most often using the PowerShell ISE. When I fire up the PowerShell ISE I often go to most recently edited files and re-open the\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"toolbox","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/08\/082115_1552_WhatWereYou1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":530,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/530\/putting-the-squeeze-on-files-with-powershell\/","url_meta":{"origin":3025,"position":4},"title":"Putting the Squeeze on Files with PowerShell","author":"Jeffery Hicks","date":"December 9, 2009","format":false,"excerpt":"My December Mr. Roboto column is now online This month\u2019s tool is a PowerShell WinForm script that uses WMI to compress files. I used PrimalForms 2009 to build the graphical interface. The interface is essentially a wizard that lets you build a WMI query to find files and compress them.\u00a0\u2026","rel":"","context":"In &quot;Mr. Roboto&quot;","block_context":{"text":"Mr. Roboto","link":"https:\/\/jdhitsolutions.com\/blog\/category\/mr-roboto\/"},"img":{"alt_text":"captured_Image.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/12\/captured_Image.png_thumb.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4112,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/","url_meta":{"origin":3025,"position":5},"title":"Scary PowerShell","author":"Jeffery Hicks","date":"October 31, 2014","format":false,"excerpt":"In honor of today's festivities, at least in the United States, I thought we'd look at some scary PowerShell. I have seen a lot of scary things in blog posts, tweets and forum discussions. Often these scary things are from people just getting started with PowerShell who simply haven't learned\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\/2014\/10\/103114_1654_ScaryPowerS1.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3025","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=3025"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3025\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}