{"record":{"id":"ade06c66e0451d1a","repo":"PowerShell/PowerShell","slug":"setaccesscontrol-objectsecurity-securitydescriptor","errorCode":null,"errorMessage":"SetAccessControl(ObjectSecurity securityDescriptor) is not implemented. TransactedRegistry related APIs should not be used.","messagePattern":"SetAccessControl\\(ObjectSecurity securityDescriptor\\) is not implemented\\. TransactedRegistry related APIs should not be used\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/System.Management.Automation/CoreCLR/CorePsStub.cs","lineNumber":211,"sourceCode":"        }\n\n        public RegistryValueKind GetValueKind(string name)\n        {\n            throw new NotImplementedException(\"GetValueKind(string name) is not implemented. TransactedRegistry related APIs should not be used.\");\n        }\n\n        public void Close()\n        {\n            throw new NotImplementedException(\"Close() is not implemented. TransactedRegistry related APIs should not be used.\");\n        }\n\n        public abstract string Name { get; }\n\n        public abstract int SubKeyCount { get; }\n\n        public void SetAccessControl(ObjectSecurity securityDescriptor)\n        {\n            throw new NotImplementedException(\"SetAccessControl(ObjectSecurity securityDescriptor) is not implemented. TransactedRegistry related APIs should not be used.\");\n        }\n\n        public ObjectSecurity GetAccessControl(AccessControlSections includeSections)\n        {\n            throw new NotImplementedException(\"GetAccessControl(AccessControlSections includeSections) is not implemented. TransactedRegistry related APIs should not be used.\");\n        }\n    }\n\n    internal sealed class TransactedRegistry\n    {\n        internal static readonly TransactedRegistryKey LocalMachine;\n        internal static readonly TransactedRegistryKey ClassesRoot;\n        internal static readonly TransactedRegistryKey Users;\n        internal static readonly TransactedRegistryKey CurrentConfig;\n        internal static readonly TransactedRegistryKey CurrentUser;\n    }\n\n    internal sealed class TransactedRegistrySecurity : ObjectSecurity","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/PowerShell/PowerShell/blob/3ff3c711bf54a18f8440f3c5190c3ac91cdc5852/src/System.Management.Automation/CoreCLR/CorePsStub.cs#L193-L229","documentation":"TransactedRegistryKey.SetAccessControl is a CoreCLR stub. Applying ACLs through the transacted registry is unsupported on PowerShell 7+, so the method throws NotImplementedException.","triggerScenarios":"Calling TransactedRegistryKey.SetAccessControl(securityDescriptor) on CoreCLR, typically via legacy transaction-scoped ACL code.","commonSituations":"Module ported from Windows PowerShell that set registry ACLs inside Start-Transaction; code reaching the internal TransactedRegistryKey type.","solutions":["Apply the ACL with RegistryKey.SetAccessControl (Microsoft.Win32.Registry) outside a transaction.","Use Set-Acl / Get-Acl on the HK: drive without -UseTransaction.","Guard with Platform.IsWindows and never use the transacted overload on CoreCLR."],"exampleFix":"// before\nTransactedRegistry.LocalMachine.SetAccessControl(sd);\n// after\nusing RegistryKey key = Registry.LocalMachine;\nkey.SetAccessControl((RegistrySecurity)sd);","handlingStrategy":"validation","validationCode":"if (!System.Management.Automation.Platform.IsWindows) {\n    throw new PlatformNotSupportedException(\"TransactedRegistry is unsupported; use Microsoft.Win32.RegistryKey.SetAccessControl().\");\n}","typeGuard":"static bool IsTransactedRegistrySupported => false;","tryCatchPattern":"try { TransactedRegistry.LocalMachine.SetAccessControl(sd); }\ncatch (NotImplementedException) {\n    using var key = Registry.LocalMachine;\n    key.SetAccessControl((RegistrySecurity)sd);\n}","preventionTips":["Apply ACLs via RegistryKey.SetAccessControl / Set-Acl (no -UseTransaction).","Audit security-management modules for transactional registry use.","Keep ACL operations outside Start-Transaction scopes."],"tags":["registry","transactions","coreclr","platform","acl","not-implemented"],"backgroundTag":null,"analyzedSha":"3ff3c711bf54a18f8440f3c5190c3ac91cdc5852","analyzedAt":"2026-08-13T10:39:10.759Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}