{"id":1444,"date":"2016-03-16T20:33:17","date_gmt":"2016-03-16T20:33:17","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=1444"},"modified":"2022-02-03T11:24:34","modified_gmt":"2022-02-03T17:24:34","slug":"powershell-crime-not-use-looping-files-running-commands","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/","title":{"rendered":"Powershell &#8211; is it a crime not to use it? Looping over files and running commands"},"content":{"rendered":"<p>So, I HAVE to bite the bullet. A colleague of mine started using it 3 months ago, another SQL mentor has been badgering me to use it (and to love bitcoin) for a LONG while. Today, I will record links to some basic looping structures. This is like unix (a good thing) but object oriented with full API access it seems. Neat! And &#8230; I am hooked now even if I am a late adopter and am finally giving up dos scripts (yet I am a unix shell junkie) \ud83d\ude41<\/p>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/714877\/setting-windows-powershell-path-variable\">adding to your path variable<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/784057\/run-a-simple-command-using-powershell-recursively-on-a-directory\">Run a simple command using PowerShell recursively on a directory<\/a><\/li>\n<\/ul>\n<p>My final commands were<\/p>\n<p>dir -recurse -include *.xec | %{pdt -fo $_.FullName}<br \/>\ndir -recurse -include *.xe* | %{migratedsp -f $_.FullName -dest $_.DirectoryName}<\/p>\n<p>where pdt is the .exe file that does something to the filenames. Note that % is a short form of foreach. The object that has the methods FullName and DirectoryName <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.io.fileinfo%28v=vs.110%29.aspx\">are listed on msdn<\/a> and is the FileInfo class that we know and love in other scripting languages.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I HAVE to bite the bullet. A colleague of mine started using it 3 months ago, another SQL mentor has been badgering me to use it (and to love bitcoin) for a LONG while. Today, I will record links to some basic looping structures. This is like unix (a good thing) but object oriented [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1444","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.<\/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:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"So, I HAVE to bite the bullet. A colleague of mine started using it 3 months ago, another SQL mentor has been badgering me to use it (and to love bitcoin) for a LONG while. Today, I will record links to some basic looping structures. This is like unix (a good thing) but object oriented [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-16T20:33:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:34+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Powershell &#8211; is it a crime not to use it? Looping over files and running commands\",\"datePublished\":\"2016-03-16T20:33:17+00:00\",\"dateModified\":\"2022-02-03T17:24:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/\"},\"wordCount\":187,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/\",\"name\":\"Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2016-03-16T20:33:17+00:00\",\"dateModified\":\"2022-02-03T17:24:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/powershell-crime-not-use-looping-files-running-commands\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Powershell &#8211; is it a crime not to use it? Looping over files and running commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.","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:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/","og_locale":"en_US","og_type":"article","og_title":"Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.","og_description":"So, I HAVE to bite the bullet. A colleague of mine started using it 3 months ago, another SQL mentor has been badgering me to use it (and to love bitcoin) for a LONG while. Today, I will record links to some basic looping structures. This is like unix (a good thing) but object oriented [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2016-03-16T20:33:17+00:00","article_modified_time":"2022-02-03T17:24:34+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Powershell &#8211; is it a crime not to use it? Looping over files and running commands","datePublished":"2016-03-16T20:33:17+00:00","dateModified":"2022-02-03T17:24:34+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/"},"wordCount":187,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/","url":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/","name":"Powershell - is it a crime not to use it? Looping over files and running commands - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2016-03-16T20:33:17+00:00","dateModified":"2022-02-03T17:24:34+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/powershell-crime-not-use-looping-files-running-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Powershell &#8211; is it a crime not to use it? Looping over files and running commands"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=1444"}],"version-history":[{"count":5,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1444\/revisions"}],"predecessor-version":[{"id":1449,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1444\/revisions\/1449"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}