Site icon WinCert

How to remove sIDHistory from AD objects using Powershell

<p>SID History is an Active Directory &lpar;AD&rpar; user account object attribute that simplifies the authorization process during the migration of Windows domains&period; This attribute is available under Windows Server 2003 and Windows 2000 environments&period;<&sol;p>&NewLine;<p><img class&equals;"alignnone size-full wp-image-1651" src&equals;"https&colon;&sol;&sol;www&period;wincert&period;net&sol;wp-content&sol;uploads&sol;2016&sol;01&sol;powershell-blue&period;jpg" alt&equals;"" width&equals;"720" height&equals;"340" &sol;><&sol;p>&NewLine;<p>Once the domain migration is complete it is advisable to clear the sIDHistory from user or group accounts to avoid possible <a href&equals;"https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;archive&sol;blogs&sol;ashleymcglone&sol;using-powershell-to-resolve-token-size-issues-caused-by-sid-history" target&equals;"&lowbar;blank" rel&equals;"noopener noreferrer">token size issues<&sol;a>&period;<&sol;p>&NewLine;<p>This guide will help you to remove sIDHistory from AD objects using Powershell&period;<&sol;p>&NewLine;<h5>How to remove sIDHistory from a single AD user<&sol;h5>&NewLine;<p>Run Powershell in elevated mode &lpar;Run as a different user&rpar; For this purpose please use your Domain Administrator credentials&period;<&sol;p>&NewLine;<p>type the following command&colon;<br &sol;>&NewLine;<code>Get-ADUser USERNAME -properties sidhistory &vert; foreach &lbrace;Set-ADUser &dollar;&lowbar; -remove &commat;&lbrace;sidhistory&equals;&dollar;&lowbar;&period;sidhistory&period;value&rcub;&rcub;<&sol;code><&sol;p>&NewLine;<p>Replace the <strong>USERNAME<&sol;strong> attribute with the username of the desired user account&period;<&sol;p>&NewLine;<p>If you receive &&num;8220&semi;<strong>Set-ADUser&colon; Insufficient access rights to perform the operation<&sol;strong>&&num;8221&semi; error message&comma; this means you don&&num;8217&semi;t have the required permissions to delete sIDHistory from user accounts&period; If you don&&num;8217&semi;t receive any error messages this means that the command was completed successfully&period;<br &sol;>&NewLine;You can check if the sIDHistory was deleted by refreshing the container in which the user account is located&period;<br &sol;>&NewLine;Before&colon; &lpar;part of the sIDHistory was removed due to security purposes&rpar;<&sol;p>&NewLine;<p><img class&equals;"alignnone size-full wp-image-3899" src&equals;"https&colon;&sol;&sol;www&period;wincert&period;net&sol;wp-content&sol;uploads&sol;2020&sol;09&sol;sid-history-1&period;png" alt&equals;"" width&equals;"352" height&equals;"40" &sol;><&sol;p>&NewLine;<p>After&colon;<br &sol;>&NewLine;<img class&equals;"alignnone wp-image-3900 size-full" title&equals;"remove sIDHistory from AD objects" src&equals;"https&colon;&sol;&sol;www&period;wincert&period;net&sol;wp-content&sol;uploads&sol;2020&sol;09&sol;sid-history-2&period;png" alt&equals;"remove sIDHistory from AD objects" width&equals;"402" height&equals;"255" &sol;><&sol;p>&NewLine;<h5>How to remove sIDHistory from Active Directory group<&sol;h5>&NewLine;<p>Run Powershell in elevated mode &lpar;Run as a different user&rpar; For this purpose please use your Domain Administrator credentials&period;<&sol;p>&NewLine;<p>type the following command&colon;<br &sol;>&NewLine;<code>Get-ADGroup GROUPNAME -properties sidhistory &vert; foreach &lbrace;Set-ADGroup &dollar;&lowbar; -remove &commat;&lbrace;sidhistory&equals;&dollar;&lowbar;&period;sidhistory&period;value&rcub;&rcub;<&sol;code><&sol;p>&NewLine;<p>Replace the GROUPNAME attribute with the Active Directory group name&period;<&sol;p>&NewLine;<p>If you receive the &&num;8220&semi;<em>Set-ADGroup &colon; Cannot validate argument on parameter &&num;8216&semi;Remove&&num;8217&semi;&period; The argument is null or an element of the argument collection contains a null value&period;<&sol;em>&&num;8221&semi; error message&comma; this means that sIDHistory has not been set for this AD group&colon;<&sol;p>&NewLine;<h5>How to remove sIDHistory for all users in Active Directory Organizational Unit<&sol;h5>&NewLine;<p>Run Powershell in elevated mode &lpar;Run as a different user&rpar; For this purpose please use your Domain Administrator credentials&period;<&sol;p>&NewLine;<p>type the following command&colon;<br &sol;>&NewLine;<code>Get-ADUser -SearchBase &OpenCurlyDoubleQuote;OU&equals;Accounts&comma;DC&equals;mydomain&comma;DC&equals;com” -Filter &lbrace;sidhistory -like '&ast;'&rcub; -properties sidhistory &vert; foreach &lbrace;Set-ADUser &dollar;&lowbar; -remove &commat;&lbrace;sidhistory&equals;&dollar;&lowbar;&period;sidhistory&period;value&rcub;&rcub;<&sol;code><&sol;p>&NewLine;<p>Replace the <strong>-SearchBase parameter<&sol;strong> with <strong>distinguishedName of the Organizational Unit<&sol;strong> and hit Enter&period;<&sol;p>&NewLine;<p>After you have performed SSID cleanup you might want to check if there&&num;8217&semi;s still AD accounts with the sIDhistory value&period; To do this the following PowerShell command can be used&colon;<&sol;p>&NewLine;<p><code>Get-aduser -filter &ast; -properties sidhistory &vert; Where sidhistory&lt&semi;&lpar;&sol;code&gt&semi;<&sol;code><&sol;p>&NewLine;<p>Hope this guide will help you to remove sIDHistory from AD objects&period; Comments are welcome&period;<&sol;p>&NewLine;

Exit mobile version