none
Need help,I need Delete roaming profiles with .V2 folders of disabled users from csv list and they home folders RRS feed

  • Question

  • Hello everyone;

    I have problem with my script.

    My target is to get list of Home Folder paths and Roaming Profile paths of disabled users, from Active Directory OU (Marked for Deletion).

    and then run some script to delete the folders from the server that hold the folders of Home Folders and Profiles.

    The main problem i'm facing with is to delete folders that contains ExampleFolder.V2 Folders also.

    How to add to script command to include the .V2 ?

    lets say i have user named "David Smith", The user is disabled and located in OU (Marked for deletion).

    David Smith have roaming profile (\\dc1\profiles\DavidSmith)

    and Home Folder (\\dc1\HomeFolders\DavidSmith)

    But also have folder (DavidSmith.V2)

    and i need delete this folder also

    Help Guys.

    Thanks you

    My PowerShell Script:

    Get-ADUser -SearchBase "OU=Marked for Deletion,OU=Disable Users,DC=Company,DC=com" -Filter * -Properties * | 
    Select-Object -Property name, profilepath, homeDirectory | 
    Export-Csv -Path "C:\profiles.csv" -NoTypeInformation | Import-Csv "C:\profiles.csv" | Select-Object $_.homeDirectory | Remove-Item ($homeDirectory + ".V2") -Force -Recurse
    write-host -foregroundcolor yellow "Delete action complete"


    Zvi Alikyan

    Sunday, March 30, 2014 3:24 PM