Friday, January 4, 2013

Script to fix that silly iis wamreg issue


Yes not too much error handling but there ya go


if (!(test-path HKCR:\)) {New-PSDrive HKCR -PSProvider Registry -Root hkey_classes_root}
$acl = get-acl -Path "HKCR:\AppID\{61738644-F196-11D0-9953-00C04FD919C1}"

IF (($acl.owner) -eq "BUILTIN\Administrators"){Write-host -ForegroundColor Green "Permissions are right"}
else
{ write-host "Owner of Key is " $acl.owner "and this will result in iis wamreg adm issues with dcom" -ForegroundColor Yellow
write-host "Setting necessary permissions"
try {$acl.setOwner([System.Security.Principal.NTAccount]"BUILTIN\Administrators")
set-acl -AclObject $acl -path "HKCR:\AppID\{61738644-F196-11D0-9953-00C04FD919C1}"
}
Catch {
  [system.exception]
  Write-Error "caught an error"
  $error
  $error.clear()
 

} finally {}
}

#sets dcom perms
$item = Get-ItemProperty .\|select launchpermission
$newvalue = [System.Byte[]]@(1, 0, 4, 128, 108, 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 2, 0, 88, 0, 3, 0, 0, 0, 0, 0, 20, 0, 11, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 5, 18, 0, 0, 0, 0, 0, 36, 0, 11, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 5, 21, 0, 0, 0, 9, 58, 42, 36, 182, 68, 228, 35, 130, 139, 166, 40, 47, 61, 0, 0, 0, 0, 24, 0, 31, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0, 0, 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0, 0, 1, 2, 0, 0, 0, 0, 0, 5, 32, 0, 0, 0, 32, 2, 0, 0)
Set-ItemProperty -Path .\ -Name LaunchPermission -value $newvalue

No comments:

Post a Comment