{"id":193,"date":"2014-02-10T13:55:53","date_gmt":"2014-02-10T19:55:53","guid":{"rendered":"http:\/\/gimpland.org\/now\/?p=193"},"modified":"2014-02-10T13:55:53","modified_gmt":"2014-02-10T19:55:53","slug":"powershell-test-if-file-exists-and-delete","status":"publish","type":"post","link":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/","title":{"rendered":"Powershell &#8211; Test If File Exists And Delete"},"content":{"rendered":"<p>Test if our file exists and delete if true.<\/p>\n<pre>$FileName = \"C:\\Path\\somefile.txt\"\r\nif (Test-Path $FileName) {\r\n  Remove-Item $FileName\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Test if our file exists and delete if true. $FileName = &#8220;C:\\Path\\somefile.txt&#8221; if (Test-Path $FileName) { Remove-Item $FileName }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","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},"jetpack_post_was_ever_published":false},"categories":[110,109],"tags":[17,114,19,111,112,113,61],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-powershell","category-programming","tag-cli","tag-delete","tag-howto","tag-powershell-2","tag-script","tag-test","tag-windows"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Powershell - Test If File Exists And Delete - gimpland.org<\/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:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Powershell - Test If File Exists And Delete - gimpland.org\" \/>\n<meta property=\"og:description\" content=\"Test if our file exists and delete if true. $FileName = &quot;C:Pathsomefile.txt&quot; if (Test-Path $FileName) { Remove-Item $FileName }\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/\" \/>\n<meta property=\"og:site_name\" content=\"gimpland.org\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-10T19:55:53+00:00\" \/>\n<meta name=\"author\" content=\"imp7\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"imp7\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/\"},\"author\":{\"name\":\"imp7\",\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/#\\\/schema\\\/person\\\/5a73603e0ec30511d5b90534c76679fb\"},\"headline\":\"Powershell &#8211; Test If File Exists And Delete\",\"datePublished\":\"2014-02-10T19:55:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/\"},\"wordCount\":17,\"commentCount\":3,\"keywords\":[\"cli\",\"delete\",\"howto\",\"powershell\",\"script\",\"test\",\"windows\"],\"articleSection\":[\"Powershell\",\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/\",\"url\":\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/\",\"name\":\"Powershell - Test If File Exists And Delete - gimpland.org\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/#website\"},\"datePublished\":\"2014-02-10T19:55:53+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/#\\\/schema\\\/person\\\/5a73603e0ec30511d5b90534c76679fb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gimpland.org\\\/now\\\/2014\\\/02\\\/powershell-test-if-file-exists-and-delete\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/#website\",\"url\":\"https:\\\/\\\/gimpland.org\\\/now\\\/\",\"name\":\"gimpland.org\",\"description\":\"Donate by bitcoin: 12E1LyKb9Wwzw3iy6V4oWpHDXkTRC6UHJ9\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gimpland.org\\\/now\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/gimpland.org\\\/now\\\/#\\\/schema\\\/person\\\/5a73603e0ec30511d5b90534c76679fb\",\"name\":\"imp7\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x\",\"caption\":\"imp7\"},\"url\":\"https:\\\/\\\/gimpland.org\\\/now\\\/author\\\/imp7\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Powershell - Test If File Exists And Delete - gimpland.org","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:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/","og_locale":"en_US","og_type":"article","og_title":"Powershell - Test If File Exists And Delete - gimpland.org","og_description":"Test if our file exists and delete if true. $FileName = \"C:Pathsomefile.txt\" if (Test-Path $FileName) { Remove-Item $FileName }","og_url":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/","og_site_name":"gimpland.org","article_published_time":"2014-02-10T19:55:53+00:00","author":"imp7","twitter_misc":{"Written by":"imp7"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/#article","isPartOf":{"@id":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/"},"author":{"name":"imp7","@id":"https:\/\/gimpland.org\/now\/#\/schema\/person\/5a73603e0ec30511d5b90534c76679fb"},"headline":"Powershell &#8211; Test If File Exists And Delete","datePublished":"2014-02-10T19:55:53+00:00","mainEntityOfPage":{"@id":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/"},"wordCount":17,"commentCount":3,"keywords":["cli","delete","howto","powershell","script","test","windows"],"articleSection":["Powershell","Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/","url":"https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/","name":"Powershell - Test If File Exists And Delete - gimpland.org","isPartOf":{"@id":"https:\/\/gimpland.org\/now\/#website"},"datePublished":"2014-02-10T19:55:53+00:00","author":{"@id":"https:\/\/gimpland.org\/now\/#\/schema\/person\/5a73603e0ec30511d5b90534c76679fb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gimpland.org\/now\/2014\/02\/powershell-test-if-file-exists-and-delete\/"]}]},{"@type":"WebSite","@id":"https:\/\/gimpland.org\/now\/#website","url":"https:\/\/gimpland.org\/now\/","name":"gimpland.org","description":"Donate by bitcoin: 12E1LyKb9Wwzw3iy6V4oWpHDXkTRC6UHJ9","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gimpland.org\/now\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/gimpland.org\/now\/#\/schema\/person\/5a73603e0ec30511d5b90534c76679fb","name":"imp7","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x","url":"https:\/\/secure.gravatar.com\/avatar\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d0544d7ec7cea4e1a78e16ae627707fdc0a3f9d32087dd9a87038b079316ac2d?s=96&d=identicon&r=x","caption":"imp7"},"url":"https:\/\/gimpland.org\/now\/author\/imp7\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4dqkb-37","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":2,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/posts\/193\/revisions\/195"}],"wp:attachment":[{"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gimpland.org\/now\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}