Link to home
Start Free TrialLog in
Avatar of creative555
creative555

asked on

Taking ownership of multiple files with the script

Hello,
I was wondering if I can get a powershell or vb script to take ownership of multiple files so that I can modify and add NTFS permissions using the script. I get access denied error when even trying to do NTFS inventory.

Below is what I need to do but not just manually for one folder, I need to fix thousands of folders. Thank you very much.


https://support.microsoft.com/en-us/kb/2623670

To take ownership of a file or folder, follow these steps:
Press and hold the folder that you want to take ownership of, then tap Properties. (If you are using a mouse, right-click the folder, and then click Properties.)
Tap or click the Security tab, tap or click Advanced, then tap or click Change. If you are prompted for an administrator password or for confirmation, type the password or provide confirmation.
Type the name of the person that you want to give ownership to, and then click Check Names.
Note The account name for the person that you are assigning ownership to is displayed.
Click OK.
If you want this person to be the owner of the files and subfolders that are contained in this folder, select the Replace owner on subcontainers and objects check box.
Click OK.
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of creative555
creative555

ASKER

I have just read that there is an issue If  taking ownership actually would break the home drive access for the user.....

 This is due to the ‘Grant user exclusive rights’ policy.

Let me know what you think. What would also be a safe and obviously non-destructive approach.
Is there way to do it through group policy?
All you need to do is test this theory on a single Share. Create a Test Share and then use the TAKEOWN command and run it against that share only, see what happens. If memory serves, i have not had an issue when i used this command in the past.

Will.
OK. Thank you so much. I will test it first and let you know if this will work :)
Thank you so much, Will! Excellent answer.