Remove-sqmAdOrphanLogin
Security sqmSQLTool v1.8.2+
Removes Windows logins whose Active Directory account no longer exists (AD orphans).

Examples

Remove-sqmAdOrphanLogin -SqlInstance "SQL01" -WhatIf
Remove-sqmAdOrphanLogin -SqlInstance "SQL01" -WhatIf
    Lists exactly which AD-orphaned logins would be removed, without changing anything.
Remove-sqmAdOrphanLogin -SqlInstance "SQL01"
Remove-sqmAdOrphanLogin -SqlInstance "SQL01"
    Removes confirmed AD-orphaned logins after a rollback backup, asking for confirmation per login.
Remove-sqmAdOrphanLogin -SqlInstance "SQL01" -ExcludeLogin 'DOMAIN\KeepThis*' -Confirm:$false
Remove-sqmAdOrphanLogin -SqlInstance "SQL01" -ExcludeLogin 'DOMAIN\KeepThis*' -Confirm:$false
    Removes confirmed orphans (except the excluded pattern) without interactive confirmation.