Rename SamAccountName and Home Directory


I really require some help on this script I’ve been working on. We currently use GPO for folder/file redirection and its giving me issues when I run this script.

We are in the process of standardizing our User login names to first letter + lastname. However, when I run this script and the user logs in, they are unable to create new folders on their desktop. They receive “No Object for Moniker error”. I’m not sure what piece of the puzzle I’m missing here and could really use some help(Note, our folder/files are on a File Server on the network). I thought it would be as easy and just renaming the folder in the file server using the Rename-Item cmdlet and than just setting the home directory to the new file path with the new name…not so. The directory is showing up as their H: drive, but they are not able to create folder/files directly on their desktops, receiving that moniker error.

Mind you, this only happens if the user logs on to the SAME PC with their new credentials. Their H: drive is there but they are unable to create folders/files on the desktop. HOWEVER, if they log on to a DIFFERENT PC, than all their old folders are there and they have no problems creating files/folders.

I think this may have to do with the registry on the local PC holding on to those old credentials but I am not sure…

Please see link to my code:
Link to code: PowerShell AD -

Thank you all for our help!

Yeah, it’s not your script - it’s a problem with the way Windows handles changes to folder redirection. Unfortunately, it’s not really a PowerShell issue per se; we’ll see if anyone jumps in with a suggestion, but you may want to post someplace broader like also.

Thank Don,

I figured the script I wrote is fine, but thought I should reach out to the community just in case.

I’ll try my luck in ServerFault.