In the assembly System.EnterpriseServices in the namespace System.EnterpriseServices.Internal we have the class Publish. The Publish class contains a method named GacRemove which takes a string as an input parameter. This string is full path to the location where the original DLL is located. If you deleted the DLL you will have to copy it from the GAC to the original location and then execute GacRemove. Reference to MSDN
The following script is the absolute bare bone script needed to remove a DLL from the GAC. Remember to replace the <FULLPATH_TO_YOUR_ORIGINAL_DLL> with the actual literal path to the original DLL.
$AssemblyFilePath = "<FULLPATH_TO_YOUR_ORIGINAL_DLL>"
[System.Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacRemove($AssemblyFilePath)
Write-Host “Assembly has been removed from the GAC”
[System.Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacRemove($AssemblyFilePath)
Write-Host “Assembly has been removed from the GAC”
Inga kommentarer:
Skicka en kommentar