OrphanedSid
1.2.0
Finds orphaned SIDs in Active Directory ACLs, removes them with a backup of every ACL it touches, and restores an ACL from that backup
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2026 Jeffrey Stuhr. All rights reserved.
Package Details
Author(s)
- Jeffrey Stuhr
Tags
ActiveDirectory AD SID OrphanedSID ACL Security Permissions Cleanup Audit Compliance Backup Restore Windows
Functions
Find-OrphanedSid Remove-OrphanedSid Restore-OrphanedSidBackup
PSEditions
Dependencies
This module has no dependencies.
Release Notes
1.2.0 - Objects that were reported and could not be cleaned, removal results that say what
happened, and critical errors with error IDs of their own.
Objects that Find-OrphanedSid reported and Remove-OrphanedSid could not reach are now cleaned and
restored: a name with [ ] * ? or a backtick, a name with & ; | or %, an object that is named by an
attribute other than CN, OU or DC, and, on Windows PowerShell 5.1, a name with a comma or another
character that Active Directory escapes. The root of a single-label domain is accepted as a
search base. A path with square brackets works for -BackupPath, -LogPath, -OutputPath and
-ConfigPath.
A removal result is Success = False when an entry that discovery reported is no longer on the
object and when every entry failed to be removed, and a hosted PowerShell 7 runspace no longer
reports a success with nothing removed. The new NotFoundSIDs property lists the entries that were
not found.
Restore-OrphanedSidBackup has a -BackupFile parameter for one object from one named file, writes
security entries to the log, and finds the backup of a target that is typed with blanks after its
commas.
Critical errors have error IDs of their own, such as ActiveDirectoryModuleMissing and
ConfigurationFileNotLoaded, and a start-up failure ends the command whatever the error action is.
A -ConfigPath file that is gone when the run starts ends the run. Importing the module fails when
one of its files does not load.
A directory server that cannot be contacted no longer costs a connect timeout for every SID. The
times in the log are text with the offset from UTC on both editions. A log detail that is named
as a secret is written as [REDACTED]. The module runs under strict mode.
Automation that matches an error ID, the text of an error, the Success of a removal or the form
of a time in the log should read the Changed section of CHANGELOG.md first.
See CHANGELOG.md for every change and the issue behind it.
FileList
- OrphanedSid.nuspec
- CHANGELOG.md
- LICENSE
- Public\Restore-OrphanedSidBackup.ps1
- Private\Core\Remove-OrphanedSidEntry.ps1
- Private\Security\Get-SecurityDescriptor.ps1
- Private\ACL\Get-AclAccessRule.ps1
- Private\Core\Start-OrchestrationWorkflow.ps1
- Private\Security\Invoke-RemovalVerification.ps1
- OrphanedSid.psd1
- Private\ACL\Get-ACLForRemoval.ps1
- Private\Core\Start-OrphanedSidSession.ps1
- Private\Security\Invoke-SecurityValidation.ps1
- OrphanedSid.psm1
- Private\ACL\Invoke-SIDRemoval.ps1
- Private\Core\Stop-OrphanedSidSession.ps1
- Private\SID\Get-SIDAnalysis.ps1
- README.md
- Private\ACL\Set-ModifiedACL.ps1
- Private\FileSystem\Initialize-LogDirectory.ps1
- Private\SID\Invoke-SIDProcessing.ps1
- Classes\MemoryManager.ps1
- Private\ActiveDirectory\Get-ADObjectFromSearchBase.ps1
- Private\Logging\Format-LogMessage.ps1
- Private\SID\New-SIDResult.ps1
- Classes\OrphanedSIDResult.ps1
- Private\ActiveDirectory\Get-ADObjectsSequential.ps1
- Private\Logging\Initialize-LoggingConfiguration.ps1
- Private\SID\Resolve-SIDIdentity.ps1
- Classes\ProcessingStatistics.ps1
- Private\ActiveDirectory\Get-DirectoryObjectAcl.ps1
- Private\Logging\Initialize-LoggingSystem.ps1
- Private\SID\Test-OrphanedSID.ps1
- Classes\RemovalOperationResult.ps1
- Private\ActiveDirectory\Invoke-ADOperationWithRetry.ps1
- Private\Logging\Write-ADOperationSecurityLog.ps1
- Private\SID\Test-SIDFormat.ps1
- Classes\RestoreOperationResult.ps1
- Private\ActiveDirectory\Set-DirectoryObjectAcl.ps1
- Private\Logging\Write-RemovalSecurityLog.ps1
- Private\SID\Test-SIDSecurity.ps1
- Classes\ScriptConfiguration.ps1
- Private\ActiveDirectory\Test-ValidDistinguishedName.ps1
- Private\Logging\Write-RestoreSecurityLog.ps1
- Private\System\Get-MemoryStatistics.ps1
- Classes\SecurityValidationResult.ps1
- Private\Backup\Get-BackupFileForRestore.ps1
- Private\Logging\Write-SecurityLog.ps1
- Private\System\Initialize-MemoryManager.ps1
- Classes\SIDAnalysisResult.ps1
- Private\Backup\Initialize-BackupFolder.ps1
- Private\Logging\Write-SecurityStructuredLogEntry.ps1
- Private\System\Invoke-GarbageCollection.ps1
- Classes\StreamingResultsManager.ps1
- Private\Backup\Invoke-RestoreWorkflow.ps1
- Private\Logging\Write-StructuredLog.ps1
- Private\System\Invoke-MemoryMonitoring.ps1
- en-US\about_OrphanedSid.help.txt
- Private\Backup\New-ACLBackup.ps1
- Private\Logging\Write-StructuredLogEntry.ps1
- Private\System\Invoke-ResourceDisposal.ps1
- en-US\OrphanedSid-Help.xml
- Private\Backup\Restore-ACLOperation.ps1
- Private\Operations\Invoke-OperationWithRetry.ps1
- Private\Utilities\Assert-DistinguishedNameInput.ps1
- Public\Find-OrphanedSid.ps1
- Private\Backup\Test-BackupIntegrity.ps1
- Private\Operations\Invoke-RemovalWorkflow.ps1
- Private\Utilities\ConvertTo-DistinguishedName.ps1
- Public\Remove-OrphanedSid.ps1
- Private\Core\Initialize-ScriptExecution.ps1
- Private\Reporting\Export-ResultCsv.ps1
- Private\Utilities\ConvertTo-NormalizedDistinguishedName.ps1
- Private\Core\Invoke-MainProcessingLogic.ps1
- Private\Reporting\Write-ProcessingSummary.ps1
- Private\Utilities\Get-OrphanedSidModuleVersion.ps1
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 1.2.0 (current version) | 10 | 11/23/2026 |
| 1.1.0 | 14 | 11/12/2026 |
| 1.0.1 | 12 | 11/9/2026 |
| 1.0.0 | 8 | 11/9/2026 |