user2782999
user2782999

Reputation: 425

Powershell ADSI ntSecurityDescriptor

Hi I'm having some trouble getting the information on who joined the computer to the domain. I can use this code but this is to be used by some non-administrative users that dont have access to the Powershell ActiveDirectory module.

Get-ADComputer myComputer -Properties ntSecurityDescriptor | Select ntSecurityDescriptor -ExpandProperty ntSecurityDescriptor

It's the owner property I am interested in here. But now to the real deal I need to make it work with ADSI

$Computer = [ADSI](([ADSISearcher]"(name=myComputer)").FindOne().Path)
$Computer.nTSecurityDescriptor
System.__ComObject

How do I "expand" the properties of the nTSecurityDescriptor using ADSI?

Upvotes: 1

Views: 3999

Answers (1)

StephenP
StephenP

Reputation: 4081

Powershell is smart enough that it will try to show you the best representation of an object with the most common properties it thinks you will need. Sometimes though you need to get the raw object underneath which you can do by using the PSBase property. Here's a link to Jeffrey Snover talking about it. Try this

$Computer = [ADSI](([ADSISearcher]"(name=myComputer)").FindOne().Path)
$Computer.PsBase.ObjectSecurity.Owner

Upvotes: 5

Related Questions