levertm
asked on
Move Users Favorites Folder and then Delete?
Hello,
My current scenario is as follows for user accounts:
\\90.244.233.10\userprofil e$\User-16 (this is their profile path)
\\90.244.233.10\userprofil e$\User-16 \Favorites (this is their favorites folder)
I need to take the above favorites folder and move it to their userhome$ folder found here:
\\90.244.233.10\userhome$\ %username% \Favorites (these folders already exist)
Then delete their complete userprofile$ folder.
How can I achieve this using powershell? I think the tricky part for me is going through each folder in userprofile$ and looking for a \Favorites folder and then matching that userprofile$ foldername to %username% since they're the same.
Thank you.
My current scenario is as follows for user accounts:
\\90.244.233.10\userprofil
\\90.244.233.10\userprofil
I need to take the above favorites folder and move it to their userhome$ folder found here:
\\90.244.233.10\userhome$\
Then delete their complete userprofile$ folder.
How can I achieve this using powershell? I think the tricky part for me is going through each folder in userprofile$ and looking for a \Favorites folder and then matching that userprofile$ foldername to %username% since they're the same.
Thank you.
ASKER
Hi becraig,
Thanks for the input, it's a good start. How do I go about talking over 100 user accounts? I would have to run this script with variable so as to not set any hard coded values for account usernames (ie: user-16)
Thanks for the input, it's a good start. How do I go about talking over 100 user accounts? I would have to run this script with variable so as to not set any hard coded values for account usernames (ie: user-16)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will generate a text file and test your code in my environment right now!
Be back later with my findings and results.
Be back later with my findings and results.
ASKER
Thank you becraig, that worked. Although I had to use the copy-item instead as the move-item gave me errors.
ok sounds good.
As a rule of thumb I always copy (just in case)
As a rule of thumb I always copy (just in case)
ASKER
I also posted this https://www.experts-exchange.com/questions/28381231/PowerShell-Set-Acl-recursively.html begraig if you're interested to take a stab :)
Open in new window
Something like above should work, very simple.
The if statement verifies if the folder exists.
If it does you proceed to move the favorites folder
Move-item
Then delete the userprofile folder
Remove-Item