How to Install an Assembly (DLL) to the GAC Using Powershell

At work I would typically use gacutil.exe to add dlls to the Global Assembly Cache (GAC), however on a new Windows 2012 server we did not have gacutil installed because we didn't install Visual Studio and didn't plan on installing it if we didn't need to. I discovered that you can use PowerShell instead of gacutil to install assemblies to the GAC by instantiating and using .NET libraries. The following code will allow you to deploy and remove dlls from the GAC using Powershell:

# NOTE: Run powershell as administrator
[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null         
[System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish

# to install a dll
$publish.GacInstall("C:Absolute PathTo Dll.dll")

# to remove a dll
$publish.GacRemove("c:Folder PathDLL.dll")

# if needed
iisreset

I hope this was of help!