Use security group in takeown command?

Greetings Powershell Gurus and beginners,

I am reaching out to you all because I have a question concerning the takeown command. I am trying to change the owner of a home folder and all sub folders for users on the network, but I am getting stuck on how to specify a security group within the command. Lets say I am trying to add a security group called:  "battleship". Below is the following command that I use:             

takeown /f  "H:\Home Folders" /a /r

I can run the above command successfully, but the problem is this will give the domain admin ownership of the folders while I am trying to add "battleship" as the owner. How would I add the security group into the above command to successfully give ownership to all home folders on my network? Any comments and/or suggestions is greatly appreciated.

June 21st, 2015 6:17pm

You are asking a question about a Windows utility command in a scripting forum.  Perhaps you should ask in the Windows forum for the OS you are working with.

You might also try to read the help for the command.  That is usually where a technician would start.

Free Windows Admin Tool Kit Click here and download it now
June 21st, 2015 6:31pm

My apologies, I thought I was in the Windows Server 2012 section. I did use the "takeown /?" command in powershell and it was helpful in showing me how to type the command correctly with the options that were presented to me.


June 21st, 2015 6:46pm

Hi Ceddy,

To change the owner of folder with specific user account in powershell, Please check the Set-Owner function in this article:

http://learn-powershell.net/2014/06/24/changing-ownership-of-file-or-folder-using-powershell/

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna

Free Windows Admin Tool Kit Click here and download it now
June 22nd, 2015 8:43am

Thank you Anna, I will try again shortly.
June 22nd, 2015 3:25pm

Anna,

Thank you for the link as it was very helpful. I now understand how to use the function. I do have another question though. How would I go about combining both the takeown command and the set-owner command. I was told that this could be a achieved as a one line command?

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2015 5:40pm

Hi Ceddy,

Based on my research, the takeown command can't specify the owner account:

Enables an administrator to recover access to a file that previously was denied, by making the administrator the owner of the file.

https://technet.microsoft.com/en-us/library/cc753024.aspx?f=255&MSPPError=-2147217396

Best Regards,

Anna

July 5th, 2015 10:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics