I need to automate the removal of profile folders on Active Directory only for certain users that I have in a .csv file, for instance:
Users
john.doe
will have certain profile folders on my server:
\\myserver\john.doe.V2
\\myserver\john.doe.V6
\\myserver\john.doe.V6-old
My question is, can I in powershell somehow instruct, that if "john.doe" matches (even partially, since there is V2, V6 and so forth) then add at the end of each folder "-REMOVE" like so:
\\myserver\john.doe.V2-REMOVE
\\myserver\john.doe.V6-REMOVE
\\myserver\john.doe.V6-old-REMOVE
I think it should be something like this?? definitely need help:
Import-CSV "C:\\users.csv" | foreach {rename-item -path \\myserver\$_.Users –Newname + "-REMOVE"}
Many thanks