{"id":297,"date":"2019-02-28T21:03:32","date_gmt":"2019-02-28T21:03:32","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=297"},"modified":"2019-02-28T21:03:43","modified_gmt":"2019-02-28T21:03:43","slug":"configmgr-run-script-clear-cm-cache-and-branchcache-cache","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/configmgr-run-script-clear-cm-cache-and-branchcache-cache\/","title":{"rendered":"ConfigMgr Run Script &#8211; Clear CM cache and BranchCache cache"},"content":{"rendered":"\n<p>We recently ran into some hash issues with content coming from BranchCache and wanted to clear out the cache on systems to wipe things clean so I did this quick script.  I set the BranchCache part inside a comment block and used a # to comment out the comment block.  This makes it so I could easily enable or disable the removal of the BranchCache part.<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;#<br>.SYNOPSIS<br>ConfigMgr Run Script to clear CMCache and BrnachCache<br><br>.SYNTAX<br>clearcache.ps1<br><br>.PARAMETER &lt;Parameter_Name><br><br>.INPUTS<br><br>.OUTPUTS<br><br>.NOTES<br>FileName: clearcache.ps1<br>Author: Michael Schultz<br>Contact: <br>Created: 20190227<br>Modified: <br>Version: 1<br><br>.EXAMPLE<br>clearcache.ps1<br><br>#><br><br>#-----Parameters-----<br><br>Param (<br><br><br>)<br>#-----Initializations and Module Imports-----<br><br>#-----Variables-----<br><br>#-----Functions-----<br><br>#-----Logging-----<br><br>#-----Execution-----<br><br>#clear CM Cache<br>$UIResourceMgr = New-Object -ComObject UIResource.UIResourceMgr<br>$Cache = $UIResourceMgr.GetCacheInfo()<br>#Enum Cache elements, compare date, and delete them<br>$Cache.GetCacheElements()  | foreach {$Cache.DeleteCacheElement($_.CacheElementID)}<br><br>#clear BranchCache - Remove first '#' below to turn of BrnachCache flush.  Add back to turn back on<br>#&lt;#<br>If([System.Environment]::OSversion.Version.Major -ge '10')<br>{<br>    Clear-BCCache -force<br>}<br>else<br>{<br>    netsh branchcache flush<br>}<br>#> <\/pre>\n\n\n\n<p>Script on GitHub at <a href=\"https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/ConfigMgr-Run-Scripts\/clearcache.ps1\">https:\/\/github.com\/NecroMonkey\/vault\/blob\/master\/ConfigMgr-Run-Scripts\/clearcache.ps1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently ran into some hash issues with content coming from BranchCache and wanted to clear out the cache on systems to wipe things clean so I did this quick script. I set the BranchCache part inside a comment block and used a # to comment out the comment block. This makes it so I &hellip; <a href=\"https:\/\/michaelschultz.net\/tech\/configmgr-run-script-clear-cm-cache-and-branchcache-cache\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ConfigMgr Run Script &#8211; Clear CM cache and BranchCache cache&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_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}},"categories":[1],"tags":[],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-4N","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":5,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":302,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/297\/revisions\/302"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}