Busy working on a script that will disable and delete the user after a specific time period and also deletes their redirected my documents folder.
ForEach ($DeletedUser in (Get-Aduser -searchbase $SearchBase30days -Filter {enabled -eq $False} ))
{ Remove-Item "\\fps01\userdata\$DeletedUser"
Remove-ADUser $DeletedUser }
When running this part the following error appears :
Cannot find path '\\fps01\userdata\CN=Piet,OU=Delete 30 Days,OU=Disabled Users,DC=Contoso,DC=local' because it does not exist
I tried to use Remove-Item "\\fps01\userdata\$DeletedUser.SamAccountName" but that didn't work either, same error message.
The path is : "\\fps01\userdata\Piet" (Based on their SamAccountName)
Is there a way to make this work?