Rich Leone wrote:
Oisin's Get-Owner and Set-Owner
06-May-09
MOW I am having the same issue, trying to set 500 owners from a text file feed. I can not find the Oisin's Get-Owner and Set-Owner cmdlet anywhere. Please advise.
VatO
Previous Posts In This Thread:
On Tuesday, June 26, 2007 6:07 AM
Jeffery Hicks wrote:
Set a new file owner
My forehead is bruised from trying to come up with simple code to set a
new owner for a file. Something like this should work
$file=".\file.txt"
[System.Security.Principal.NTAccount]$newOwner="mydomain\roygbiv"
$var=get-item $file
$acl=$var.GetAccessControl()
$acl.SetOwner($NewOwner)
$var.SetAccessControl($acl)
But I always get: Exception calling "SetAccessControl" with "1"
argument(s): "The security identifier is not allowed to be the owner of
this object."
I'm doing this on a Windows 2003 SP2 server. I can assign the owner in
the GUI.
I can also get this far:
PS C:\public> $x=get-acl $file
PS C:\public> $x.SetOwner($newOwner)
Looking at $x shows the new owner. But I can't find a way to "set" the
new owner. I don't know if I'm using the wrong principal type or what.
I've also tried variations with Get-Acl and Set-Acl, but also with no luck.
I found some older posts on mucking around with principal policies but
that looked like pre-release code.
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.
"Those who forget to script it are doomed to repeat it."
On Wednesday, June 27, 2007 1:24 PM
oMV wrote:
Jeffery,you can only set it to administrators or your account,this is a
Jeffery,
you can only set it to administrators or your account,
this is a "security" restriction I think (not a good one, as the good guys
need it hardly (quota etc) and the bad guys can do it anyway) , with the GUI
support I did think MS finaly realised that
and Yes !!
I got SetOwner working in Monad beta 2, that also had the Beta 2.0 framework
and added it to my typeinfo
http://mow001.blogspot.com/2005/10/getting-and-using-securityprincipal.html
I was very glad with it, finaly
but it does not work anymore in powershell 1.0 (.NET 2.0 RTM ) seems they
removed the support for setting a owther owner again in the final 2.0
framework.
grrr.
Greetings /\/\o\/\/
"Jeffery Hicks" wrote:
On Wednesday, June 27, 2007 2:10 PM
Jeffery Hicks wrote:
Re: Set a new file owner
//o// [MVP] wrote:
Since I could do it in the GUI (which you could never do before), I was
still hoping to do it from PowerShell but it apparently isn't meant to
be. I suppose the workaround is to add an ACL to give the user the
TakeControl permission.
At least now I can stop banging my head on my desk.
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.
blog: http://blog.SAPIEN.com
Community: http://www.scriptinganswers.com
Training: http://www.ScriptingTraining.com
Books: http://www.SAPIENPress.com
Editor: http://www.primalscript.com
Tools: http://www.scriptingoutpost.com
"Those who forget to script it are doomed to repeat it."
On Wednesday, June 27, 2007 2:18 PM
/\\/\\o\\/\\/ [MVP] wrote:
big disapointment for me also but you can still do it using API'sI made a
big disapointment for me also but you can still do it using API's
I made a setowner in VB.NET before, as it did work in the beta I was glad I
did not need it anymore, but now I have to search for the source
again or better yet I have to find a opensource .NET library I can steal,
uhh use now , and load into powershell.
keep you posted ;-)
Greetings /\/\o\/\/
"Jeffery Hicks" <jhi...@sapien.com> wrote in message
news:Owd6AaO...@TK2MSFTNGP06.phx.gbl...
On Wednesday, June 27, 2007 2:34 PM
/\\/\\o\\/\\/ [MVP] wrote:
Re: Set a new file owner
@ PSCX ;-)
the API wrappers needed are in here :
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9
please ;-)
as I did this in VS2002 it's a bit rusty
Greetings /\/\o\/\/
"/\/\o\/\/ [MVP]" <mow...@hotmail.NoSpam> wrote in message
news:27E0838B-D33D-465E...@microsoft.com...
On Wednesday, June 27, 2007 3:36 PM
oMV wrote:
b.t.w. ofcourse SubinAcl still works in powershell.
b.t.w. ofcourse SubinAcl still works in powershell.
but only for this a bit much overhead and setowner.exe is not AV proof ;-)
"/\/\o\/\/ [MVP]" wrote:
On Wednesday, June 27, 2007 6:36 PM
Jeffery Hicks wrote:
Re: Set a new file owner
//o// [MVP] wrote:
I've confirmed that this WILL work:
$file=".\file.txt"
[System.Security.Principal.NTAccount]$newOwner="Administrators"
$var=get-item $file
$acl=$var.GetAccessControl()
$acl.SetOwner($NewOwner)
$var.SetAccessControl($acl)
The new owner must be the Administrators group or a domain admin
account. This is true on XP and Windows 2003 SP2. Even though the 2003
GUI lets you assign ownership, PowerShell can't.
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.
blog: http://blog.SAPIEN.com
Community: http://www.scriptinganswers.com
Training: http://www.ScriptingTraining.com
Books: http://www.SAPIENPress.com
Editor: http://www.primalscript.com
Tools: http://www.scriptingoutpost.com
"Those who forget to script it are doomed to repeat it."
On Thursday, July 12, 2007 6:52 PM
oMV wrote:
/\/\o\/\/ is glad to anounce, Coming soon in a Shell near you ..
/\/\o\/\/ is glad to anounce, Coming soon in a Shell near you ..
Oisin's Get-Owner and Set-Owner :
PoSH> Get-Owner test1.ps1
Value
-----
BUILTIN\Administrators
PoSH> Set-Owner test1.ps1 -AccountName User1
Set-Owner F:\PowerShell\test\test1.ps1
Change owner from BUILTIN\Administrators to User1?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
PoSH> Get-Owner test1.ps1
Value
-----
POSHWORKS\User1
Kudos and much thanks to X0N, for making this great cmdlets for me and the
rest of the community, not more SubInAcl !!.
this Cmdlet will be available in PSCX 1.2 and will be posted tomorrow on my
blog .
wow again, what a great PowerShell community we have !!!
Greetings /\/\o\/\/
"Jeffery Hicks" wrote:
On Thursday, August 09, 2007 8:26 PM
dinonator wrote:
Re: Set a new file owner
'/\/\o\/\/ [MVP Wrote:
--
dinonator
On Wednesday, May 06, 2009 10:50 AM
Rich Leone wrote:
Oisin's Get-Owner and Set-Owner
MOW I am having the same issue, trying to set 500 owners from a text file feed. I can not find the Oisin's Get-Owner and Set-Owner cmdlet anywhere. Please advise.
VatO
Submitted via EggHeadCafe - Software Developer Portal of Choice
A Comparison of Managed Compression Algorithms
http://www.eggheadcafe.com/tutorials/aspnet/71485ecc-2d2d-435a-9c35-3d12b279f9ae/a-comparison-of-managed-compression-algorithms.aspx