Avatar of creative555
creative555

asked on 

powershell script to switch ownership of the files.

Hello,
Could you please recommend powershell script to switch ownership of the files.
For example from user@Source.com to the user@TARGET.com

Our users were re-created from scratch in the target forest, so we need to have a script to change ownerships of files from source users to target users.
We have a different naming convention in the target for users, so the script would need to read the input excel file where I have listed the directories and new owners for the files.

Is it possible? Please help. Thank you very much!
PowershellScripting Languages

Avatar of undefined
Last Comment
creative555
ASKER CERTIFIED SOLUTION
Avatar of unrealized92
unrealized92

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of creative555
creative555

ASKER

Thank you so much! I checked subinacl and it is a great tool indeed but not very user friendly.
What would be a command use input excel file with current owners and directories that I need to change ownerships for?
Avatar of creative555
creative555

ASKER

thanks!!
Avatar of creative555
creative555

ASKER

I will just run it line by line and copy from excel. this will work. Thank you
Avatar of creative555
creative555

ASKER

hello,
Solution is just to do a batch file and run line by line like this. It is easier just to copy and paste from excel all the shares and save it as the batch file.

subinacl /file test.txt /setowner=domain\foo
subinacl /file test.txt /setowner=domain\foo
subinacl /file test.txt /setowner=domain\foo
Avatar of creative555
creative555

ASKER

This was a resolution. I just didn't realize i can run many lines in the batch file. :) THank you
Scripting Languages
Scripting Languages

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

30K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo