I am writing a script to reset roaming profiles and it is failing at a part which basically:
- Changes ownership of a Folder and subfolders (the user profile)
- Copies it to a Temp folder
- Removes the original
To change ownership I use takeown:
takeown /s \\profile-server /f e:\Profiles\%username% /r /d Y
This is run from a domain admin account so permissions are fine. I then get the following output:
SUCCESS: The file (or folder): "\\profile-server\e$\Profiles\%username%" now owned by user "domain\user".
ERROR: The data area passed to a system call is too small
So it changes ownership of the top most folder but fails at the first sub-item.
I have tried this on 2 computers on the network and it works fine but as soon as I change the computer to the profile server this error comes.
Any ideas?
Thanks
In order to rectify this all I had to do was use PsExec in order to run the command, so:
And it allowed me to recursively take ownership of all the files.