Skip to content

Instantly share code, notes, and snippets.

@andrewtchilds
Created March 23, 2018 03:44
Show Gist options
  • Save andrewtchilds/64de720eaf315d6d247d21b0f48d3920 to your computer and use it in GitHub Desktop.
Save andrewtchilds/64de720eaf315d6d247d21b0f48d3920 to your computer and use it in GitHub Desktop.
Repairs the MpsSvc service registry key permissions... if they're missing
$keyPath = "SYSTEM\CurrentControlSet\Services\MpsSvc\Parameters\AppCs"
$permissionCheck = [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree
$registryRights = [System.Security.AccessControl.RegistryRights]::ChangePermissions
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($keyPath,$permissionCheck,$registryRights)
$acl = $key.GetAccessControl()
if(-not ($acl.Access | ? { $_.IdentityReference.Value -eq "NT SERVICE\MpsSvc" }) ) {
$rule = [System.Security.AccessControl.RegistryAccessRule]::new("NT SERVICE\MpsSvc","SetValue, CreateSubKey, Delete, ReadKey","ContainerInherit","None","Allow")
$acl.SetAccessRule($rule)
$key.SetAccessControl($acl)
}
if((Get-Service MpsSvc).Status -ne "Running") {
Start-Service MpsSvc
}
@andrewtchilds
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment