![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | changing file ownership, "powershell way", anyone? Hello everybody, I've googled this group and elsewhere without finding answer to my question. What is the "powershell way" to change file ownership? Even in this newsgroups I've found only answers to this question using "subinacl". Could somebody give information to do this inside powershell? Thanks in advance, -- Gilles "Cool Raoul" - http://coolraoul.cvp-net.com/ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: changing file ownership, "powershell way", anyone? these blogentries might help http://mow001.blogspot.com/2006/01/a...le-acl-in.html http://mow001.blogspot.com/2005/10/m...r-working.html http://mow001.blogspot.com/2005/10/u...-to-types.html greetings /\/\o\/\/ http://ThePowerShellGuy.com "Gilles Pion" <nosuchuser@nosuchdomain.com> wrote in message news okcp2tfboc333a341g5p3i1n176stfce7@4ax.com...> Hello everybody, > > I've googled this group and elsewhere without finding answer to my > question. > > What is the "powershell way" to change file ownership? > > Even in this newsgroups I've found only answers to this question using > "subinacl". > > Could somebody give information to do this inside powershell? > > Thanks in advance, > > -- > Gilles "Cool Raoul" - http://coolraoul.cvp-net.com/ |
My System Specs![]() |
| | #3 (permalink) |
| | Re: changing file ownership, "powershell way", anyone? Ref: <8B64BB69-D6C4-4304-A1DE-2E4030A8E12C@microsoft.com> de "/\\/\\o\\/\\/ [MVP]" <mow001@hotmail.NoSpam> >these blogentries might help > >http://mow001.blogspot.com/2006/01/a...le-acl-in.html >http://mow001.blogspot.com/2005/10/m...r-working.html >http://mow001.blogspot.com/2005/10/u...-to-types.html Thanks, I had already noticed those pages but I have been unable reproduce the examples: PS M:\var\tmp> (gi test.txt).get_owner() Method invocation failed because [System.IO.FileInfo] doesn't contain a method named 'get_owner'. At line:1 char:24 + (gi test.txt).get_owner( <<<< ) It seems that my powershell implementation doesn't know about "get_owner" (and "set_owner" too) methods Anyway, the following script seems to work partially (only when the owner is myself or a group I belongs to) ================================================================== function f_chown { param( [System.object]$the_file, [system.security.principal.ntaccount]$the_owner ) $acl = ($the_file | get-Acl ) $acl.setowner($the_owner) $the_file | set-Acl -aclobject $acl } $accountname=$args[0] $filename =$args[1] $account= new-object system.security.principal.ntaccount($accountname) $fileobj = (get-Item $filename) f_chown $fileobj $accountname ================================================================== -- Gilles "Cool Raoul" - http://coolraoul.cvp-net.com/ |
My System Specs![]() |
| | #4 (permalink) |
| | Re: changing file ownership, "powershell way", anyone? the get_owner() Methods are custom methods I did make (in the post about typedata), to make it more easy to reach in the update typedate post I explain how I did add them Greetings /\/\o\/\/ "Gilles Pion" <nosuchuser@nosuchdomain.com> wrote in message news:lu3fp2t87vpie92uu6lutjgrhl9e1vq1dk@4ax.com... > Ref: <8B64BB69-D6C4-4304-A1DE-2E4030A8E12C@microsoft.com> de > "/\\/\\o\\/\\/ > [MVP]" <mow001@hotmail.NoSpam> >>these blogentries might help >> >>http://mow001.blogspot.com/2006/01/a...le-acl-in.html >>http://mow001.blogspot.com/2005/10/m...r-working.html >>http://mow001.blogspot.com/2005/10/u...-to-types.html > > > Thanks, I had already noticed those pages but I have been unable reproduce > the > examples: > > PS M:\var\tmp> (gi test.txt).get_owner() > Method invocation failed because [System.IO.FileInfo] doesn't contain a > method > named 'get_owner'. > At line:1 char:24 > + (gi test.txt).get_owner( <<<< ) > > It seems that my powershell implementation doesn't know about "get_owner" > (and > "set_owner" too) methods > > > > Anyway, the following script seems to work partially (only when the owner > is > myself or a group I belongs to) > ================================================================== > function f_chown { > param( > [System.object]$the_file, > [system.security.principal.ntaccount]$the_owner > ) > $acl = ($the_file | get-Acl ) > $acl.setowner($the_owner) > $the_file | set-Acl -aclobject $acl > } > > > $accountname=$args[0] > $filename =$args[1] > $account= new-object system.security.principal.ntaccount($accountname) > $fileobj = (get-Item $filename) > > > f_chown $fileobj $accountname > ================================================================== > -- > Gilles "Cool Raoul" - http://coolraoul.cvp-net.com/ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| "Extensible Authentication Protocol" service gives "The system cannot find the file specified" error | Vista networking & sharing | |||
| Shortcut changes when changing attribute from "Normal window" to "Maximized" | Vista General | |||
| PowerShell installation problem - Vista - "This machine disabled for file encryption." | PowerShell | |||
| Deleted "music" folder, can't take ownership of replacement. | Vista file management | |||
| Changing "mailto" protocol via registry--no "clients" file under HKEY_USERS | Vista mail | |||