{"id":3527,"date":"2012-04-17T13:33:13","date_gmt":"2012-04-17T13:33:13","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/powershell-script-for-removing-all-assemblies-in-a-folder\/"},"modified":"2016-07-28T10:50:46","modified_gmt":"2016-07-28T10:50:46","slug":"powershell-script-for-removing-all-assemblies-in-a-folder","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/powershell-script-for-removing-all-assemblies-in-a-folder\/","title":{"rendered":"PowerShell Script for Removing All Assemblies in a Folder"},"content":{"rendered":"<p>You may have seen my blog post on how to add all of the assemblies from a folder into the GAC.&#160; Here is a quick PowerShell script to do the reverse &#8211; it looks through a list of assemblies in a folder and removes them from the GAC:<\/p>\n<p>$gacUtilLocation = &#8220;C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64gacutil.exe&#8221;;<\/p>\n<p>get-childitem * -include *.dll,*.exe | foreach-object {    <br \/>&#160;&#160;&#160; Write-Host &#8220;Removing&#8221; $asm.FullName    <br \/>&#160;&#160;&#160; $asm = [System.Reflection.Assembly]::LoadFile($_)    <br \/>&#160;&#160;&#160; $command = &#8220;&amp;`&#8221;{0}`&#8221;\/nologo \/u `&#8221;{1}`&#8221;&#8221; -f $gacUtilLocation,$asm.FullName&#160;&#160;&#160; <br \/>&#160;&#160;&#160; invoke-expression $command    <br \/>}    <\/p>\n<p>I find this helpful in SharePoint to make sure the GAC is clear of any of my development assemblies before doing a proper deployment from a WSP.&#160; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may have seen my blog post on how to add all of the assemblies from a folder into the GAC.&#160; Here is a quick PowerShell script to do the reverse &#8211; it looks through a list of assemblies in a folder and removes them from the GAC: $gacUtilLocation = &#8220;C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64gacutil.exe&#8221;; get-childitem&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3527","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3527"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3527\/revisions"}],"predecessor-version":[{"id":42146,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3527\/revisions\/42146"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3527"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}