Remove a Specific SIDhistory

This topic contains 4 replies, has 2 voices, and was last updated by  Marti 2 weeks, 4 days ago.

  • Author
    Posts
  • #82195

    Marti
    Participant

    Hi,

    I'm tried to delete some specific SIDHistory after a lot of migrations. I have a problem with my script because if some objects has more than 1 SIDHistory, it clear all of them and I don't want that.

    $SID_Recherche = S-1-5-21-2952651426-2628096683-2210756013
    $CheminArborescence = "OU=TOTO, OU=TOTO, OU=_TOTO, DC=TEST, DC=local"
    
    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force
    
    #Import du module AD
    Import-Module ActiveDirectory
    Import-Module SIDHistory
    
    Get-SIDHistory -SearchBase $CheminArborescence –DomainSID $SID_Recherche | export-csv C:\Users\A003634\Desktop\ScopedSIDHistory.csv
    
    Get-SIDHistory -SearchBase $CheminArborescence  –DomainSID $SID_Recherche  | Remove-SIDHistory | Export-CSV C:\Users\A003634\Desktop\RemovedSIDhistory.csv

    For example, I want to choose object with this SIDHistory S-1-5-21-2952651426-2628096683-2210756013 but if the object got many SIDHistory, it delete all of them.
    How can I do it better ?

    Thank you

  • #82286

    Marti
    Participant

    Someone now something about this ?

  • #82411

    Rick
    Participant

    I haven't tested this but would this work?

    $SID_Recherche = S-1-5-21-2952651426-2628096683-2210756013
    $CheminArborescence = "OU=TOTO, OU=TOTO, OU=_TOTO, DC=TEST, DC=local"
    
    Get-aduser -filter * -SearchBase $CheminArborescence | Set-ADUser $_ -Remove @{SIDHistory=$SID_Recherche}
    
    
  • #82606

    Marti
    Participant

    Hi,

    I can't because I need an Identity Parameters :

    Set-ADUser : Impossible de valider l'argument sur le paramètre « Identity ». L'argument est null. Indiquez un argument non-null et réessayez.
    Au niveau de ligne : 12 Caractère : 66
    + Get-aduser -filter * -SearchBase $CheminArborescence | Set-ADUser <<<< $_ -Remove @{SIDHistory=$SID_Recherche} | export-csv C:\Users\A003634\Desktop\ScopedSIDHistory.csv + CategoryInfo : InvalidData: (:) [Set-ADUser], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.SetADUser

  • #83236

    Marti
    Participant

    UP

    Anyone ?

You must be logged in to reply to this topic.