{"id":4112,"date":"2014-10-31T12:54:56","date_gmt":"2014-10-31T16:54:56","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4112"},"modified":"2014-10-31T13:10:37","modified_gmt":"2014-10-31T17:10:37","slug":"scary-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/","title":{"rendered":"Scary PowerShell"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.jpg\" alt=\"\" width=\"161\" height=\"241\" \/>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 enough yet to know better. Although I have seen some of these things from people who appear to be a bit more experienced. I find these things scary because I think they are \"bad\" examples of how to use PowerShell. Often these examples will work and provide the desired result, but the journey is through a terrifying forest. Please note that PowerShell style is subjective but I think many of the core concepts I want to show you are sound.<\/p>\n<p>First, here is a chunk of scary PowerShell code. This is something I wrote based on a number of \"bad\" techniques I've encountered.<\/p>\n<pre class=\"lang:ps decode:true \">$h = \"Name,Type,Size,LastModified,Path\" \r\n$h &gt; c:\\work\\report.csvc \r\n$files = dir c:\\work\\ -file -Recurse | where {$_.length -gt 1048576} | where {$_.LastWriteTime -gt \"1\/1\/2014\"} \r\nforeach ($file in $files) { \r\n$filetype = $file.name.substring($file.Name.LastIndexOf(\".\")) \r\n$data = $file.name+\",\"+$filetype+\",\"+$file.Length+\",\"+$file.LastWriteTime+\",\"+$file.FullName \r\n$data &gt;&gt; c:\\work\\report.csv } \r\n}<\/pre>\n<p>This code will create a CSV file with files in C:\\Work that are over a certain size and modified after January 1, 2014. When I see code like this I am pretty confident the author is coming from a VBScript background. To me, I see a lot of energy working with text. I'll come back to that point in a moment.<\/p>\n<p>First, filtering is a bit ugly. Unless you have a specific byte value in mind, use shortcuts like 1MB which is easier to understand than 104876. You can also combine filters into one.<\/p>\n<pre><code>$files = dir c:\\work\\ -file -Recurse | where {$_.length -gt 1MB \u2013AND $_.LastWriteTime -gt \"1\/1\/2014\"}<\/code><\/pre>\n<p>I cringe when I see people trying to concatenate values in PowerShell. In this case it simply isn't needed. But for the sake of learning, if you really needed to build a string, take advantage of variable expansion. Here I will need to use a sub-expression.<\/p>\n<pre class=\"lang:ps decode:true \">$data = \"$($file.name),$($filetype),$($file.Length),$($file.LastWriteTime),$($file.FullName)\"<\/pre>\n<p>But in the example of bad code ,instead of manually creating a CSV file, PowerShell can do that for you with Export-CSV.\u00a0 In the code sample, the header is different than the property names, but that's OK. We can use a hashtable with Select-Object and create something new.<\/p>\n<pre><code>dir c:\\work\\ -file -Recurse | \r\nwhere {$_.length -gt 1MB -AND $_.LastWriteTime -gt \"1\/1\/2014\"} |\r\nSelect-Object Name,Extension,@{Name=\"Size\";Expression={$_.length}},\r\n@{Name=\"LastModified\";Expression={$_.Lastwritetime}},\r\n@{Name=\"Path\";Expression={$_.fullname}} |\r\nExport-Csv -Path C:\\work\\report2.csv -NoTypeInformation<\/code><\/pre>\n<p>The original code used text parsing to get the file extension. But if you pipe a file object to Get-Member, you would discover there is a property called Extension. When building scripts, pipe objects to Get-Member or Select-Object with all properties to discover what you have to work with. The original code is written with the assumption that the CSV file will be used outside of PowerShell. If that is the case, then export it without type information. But if you think you will import the data back into PowerShell, include the type information because it will help PowerShell reconstruct the objects. You would learn all of this by looking at help and examples for Export-CSV.<\/p>\n<p>The example above is technically a one-line command. But it doesn't have to be. It might make more sense to break things up into discrete steps.<\/p>\n<pre><code>$files = dir c:\\work\\ -file -Recurse | \r\nwhere {$_.length -gt 1MB -AND $_.LastWriteTime -gt \"1\/1\/2014\"} \r\n\r\n$data = foreach ($file in $files) {\r\n$file | Select-Object -property Name,Extension,\r\n@{Name=\"Size\";Expression={$_.length}},\r\n@{Name=\"LastModified\";Expression={$_.Lastwritetime}},\r\n@{Name=\"Path\";Expression={$_.fullname}}\r\n}\r\n\r\n$data | Export-Csv -Path C:\\work\\report2.csv -NoTypeInformation<\/code><\/pre>\n<p>This code is sort of a compromise and isn't too difficult to follow, even if you are new to PowerShell. This would give you the same result.<\/p>\n<pre><code>$files = dir c:\\work\\ -file -Recurse | \r\nwhere {$_.length -gt 1MB -AND $_.LastWriteTime -gt \"1\/1\/2014\"} \r\n\r\n$data = $files | Select -property Name,Extension,\r\n@{Name=\"Size\";Expression={$_.length}},\r\n@{Name=\"LastModified\";Expression={$_.Lastwritetime}},\r\n@{Name=\"Path\";Expression={$_.fullname}}\r\n\r\n$data | Export-Csv -Path C:\\work\\report2a.csv -NoTypeInformation<\/code><\/pre>\n<p>Sometimes using the ForEach enumerator is faster than using ForEach-Object in a pipeline. You have to test with Measure-Command. If you are running PowerShell v4, you can take advantage of the new Where() method which can dramatically improve performance.<\/p>\n<pre><code>$files = (dir c:\\work\\ -file -Recurse).where({$_.length -gt 1MB -AND $_.LastWriteTime -gt \"1\/1\/2014\"}) \r\n$files | Select Name,Extension,@{Name=\"Size\";Expression={$_.length}},\r\n@{Name=\"LastModified\";Expression={$_.Lastwritetime}},\r\n@{Name=\"Path\";Expression={$_.fullname}} | \r\nExport-Csv -Path C:\\work\\report3.csv \u2013NoTypeInformation<\/code><\/pre>\n<p>By now I hope you can see how this code is taking advantage of cmdlets and the pipeline. For example, Export-CSV has a \u2013NoClobber parameter which prevents you from overwriting an existing file. You can't do that with legacy redirection operators like &gt; and &gt;&gt; without additional commands.<\/p>\n<p>The final step with my scary code, which now isn't quite so scary I hope, is to turn this into something re-usable. If you put the above into a script as-is, you would have to edit the file every time you wanted to check a different folder or export to a different file. This is where we can turn it from a pumpkin into a fantastic carriage, that won't revert at midnight.<\/p>\n<pre><code>Function Get-MyFiles {\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[ValidateScript({Test-Path $_})]\r\n[string]$Path=\".\",\r\n[ValidateNotNullorEmpty()]\r\n[scriptblock]$Filter={$_}\r\n)\r\n\r\nWrite-Verbose \"Processing $path\"\r\n#get files\r\n$files = dir -Path $path -Recurse\r\n\r\n#filter if necessary\r\n$files | where -FilterScript $filter | \r\nSelect-Object Name,Extension,@{Name=\"Size\";Expression={$_.length}},\r\n@{Name=\"LastModified\";Expression={$_.Lastwritetime}},\r\n@{Name=\"Path\";Expression={$_.fullname}} \r\n\r\n\r\n} #end function<\/code><\/pre>\n<p>This function gives me a flexible tool. All I need to do is specify a path, although it defaults to the current directory, and some sort of filtering script block. The default is to display everything. Now I can run a command \\ like this:<\/p>\n<pre><code>get-myfiles d:\\data-Filter {$_.length -gt 5mb}<\/code><\/pre>\n<p>You'll notice that my function doesn't export anything to a CSV file. Of course not. The function's only purpose is to get files and display a subset of properties. Because the function writes to the pipeline I can do whatever I need. Perhaps today I need to export to a CSV file but tomorrow I want to create formatted table saved to a text file.<\/p>\n<pre><code>get-myfiles D:\\VM\\ -filter {$_.extension -match \"vhd\" -AND $_.lastwritetime -le \"10\/1\/2014\"} | export-csv c:\\reports\\oldvhd.csv\r\nget-myfiles c:\\work -Verbose -Filter {$_.length -gt 5mb} | format-table | out-file c:\\reports\\WorkFiles.txt \u2013encoding ascii<\/code><\/pre>\n<p>I hope PowerShell in general doesn't frighten you. As the saying goes, we fear that which we don't understand. But once you understand some basic PowerShell principals and concepts I think you'll find it not quite as terrifying.<\/p>\n<p>What scary PowerShell have you come across<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In honor of today&#8217;s festivities, at least in the United States, I thought we&#8217;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&#8217;t learned enough yet to know better&#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 from the blog: Scary #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":[60,4,8],"tags":[534,540],"class_list":["post-4112","post","type-post","status-publish","format-standard","hentry","category-best-practices","category-powershell","category-scripting","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>Scary PowerShell &#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\/4112\/scary-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scary PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"In honor of today&#039;s festivities, at least in the United States, I thought we&#039;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&#039;t learned enough yet to know better....\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-31T16:54:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-10-31T17:10:37+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Scary PowerShell\",\"datePublished\":\"2014-10-31T16:54:56+00:00\",\"dateModified\":\"2014-10-31T17:10:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/\"},\"wordCount\":842,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/103114_1654_ScaryPowerS1.jpg\",\"keywords\":[\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Best Practices\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/\",\"name\":\"Scary PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/103114_1654_ScaryPowerS1.jpg\",\"datePublished\":\"2014-10-31T16:54:56+00:00\",\"dateModified\":\"2014-10-31T17:10:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/103114_1654_ScaryPowerS1.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/103114_1654_ScaryPowerS1.jpg\",\"width\":161,\"height\":241},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4112\\\/scary-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Best Practices\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/best-practices\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scary PowerShell\"}]},{\"@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":"Scary PowerShell &#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\/4112\/scary-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Scary PowerShell &#8226; The Lonely Administrator","og_description":"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 enough yet to know better....","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-10-31T16:54:56+00:00","article_modified_time":"2014-10-31T17:10:37+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Scary PowerShell","datePublished":"2014-10-31T16:54:56+00:00","dateModified":"2014-10-31T17:10:37+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/"},"wordCount":842,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.jpg","keywords":["PowerShell","Scripting"],"articleSection":["Best Practices","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/","name":"Scary PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.jpg","datePublished":"2014-10-31T16:54:56+00:00","dateModified":"2014-10-31T17:10:37+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/103114_1654_ScaryPowerS1.jpg","width":161,"height":241},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4112\/scary-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Best Practices","item":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},{"@type":"ListItem","position":2,"name":"Scary PowerShell"}]},{"@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":404,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/404\/5-minute-powershell\/","url_meta":{"origin":4112,"position":0},"title":"5 Minute PowerShell","author":"Jeffery Hicks","date":"September 28, 2009","format":false,"excerpt":"My October Mr. Roboto column is now available online. The article contains my suggestions for how someone completely new to PowerShell might spend their first 5 minutes. Perhaps not literally, since I expect most people will want to spend more than 60 seconds on my suggested steps. But overall I\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/09\/zrtn_001p595cc73_tn.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":87,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/87\/powershell-help-examples\/","url_meta":{"origin":4112,"position":1},"title":"Powershell Help Examples","author":"Jeffery Hicks","date":"January 15, 2007","format":false,"excerpt":"It may seem like a little thing, but the Get-Help cmdlet in PowerShell has some features you may not be aware of. I'm always using the -full parameter to see all the help information, primarily so I can see the examples. Well Get-Help has a -examples switch which won't display\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":122,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/122\/prof-powershell\/","url_meta":{"origin":4112,"position":2},"title":"Prof. PowerShell","author":"Jeffery Hicks","date":"December 5, 2007","format":false,"excerpt":"As many of you know, I write the popular Mr. Roboto column for REDMOND magazine. Starting in January, I will be taking on a new title, Professor PowerShell. The weekly Windows Tip Sheet column I've been doing for MCPMag.com will be come Prof. PowerShell. The column will still be weekly,\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":2125,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2125\/powershell-ise-addon-modulemenu\/","url_meta":{"origin":4112,"position":3},"title":"PowerShell ISE AddOn ModuleMenu","author":"Jeffery Hicks","date":"February 24, 2012","format":false,"excerpt":"Recently I did an online presentation on ISE Addons. As I was preparing for the talk one thing led to another, as they usually do when I'm working in PowerShell, and before I knew it I had a new add-on for the PowerShell ISE. This addon creates a menu for\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/modulemenu-300x136.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":4112,"position":4},"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":579,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/579\/powershell-picasso\/","url_meta":{"origin":4112,"position":5},"title":"PowerShell Picasso","author":"Jeffery Hicks","date":"February 23, 2010","format":false,"excerpt":"You have probably heard the story (or legend) about Pablo Picasso and his napkin drawing. A guy goes up to Picasso in a cafe and asks for an autograph or something. Picasso sketches out something in a minute or so. He turns to the guy and says, \u201cThat will be\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"powershell--picasso","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/02\/powershellpicasso_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4112","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=4112"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4112\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}