[PowerShell] Register DLL

#Requires WinRM access (otherwise rewrite for use with psexec)
$Servers = "server1","server2","server3"
foreach ($Server in $Servers)
{
$arch = (gwmi win32_computersystem -cn $Server).SystemType
if ($arch -like "*64*")
{
copy-item "\\server\folder\example.dll" \\$Server\C$\Windows\SysWow64\
$Scriptblock =
{
cd \windows\syswow64
regsvr32 example.dll
}
}
elseif ($arch -like "*86*")
{
copy-item "\\server\folder\example.dll" \\$Server\C$\Windows\System32\
$Scriptblock =
{
cd \windows\System32
regsvr32 example.dll
}
}
if (invoke-command $Server -scriptblock $Scriptblock)
{
write-host "-------------------------------"
write-host "Name: $Server"
write-host "Status: DLL registered"
}
else
{
write-host "-------------------------------"
write-host "Name: $Server"
write-host "Status: DLL not registered" -fore red
}
}