Group:  English: General ยป microsoft.public.windows.powershell
Thread: PowerShell access to AD user Terminal Services attributes

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

PowerShell access to AD user Terminal Services attributes
John Yarborough 12.07.2007 14:50:02
I've been looking at using PowerShell to help me manage my users in Active
Directory and so far I like everything that I am seeing. I have ran into an
issue though where I can not figure out how to access the users' Terminal
Services attributes.



Here is the command I am using to get the user information from Active
Directory:




Code Snippet
Get-WMIObject -class ds_user -namespace root\directory\ldap -computername .
| Select-Object DS_SAMAccountName






If I pipe it to Get-Member instead of Select-Object, I see a property called
ds_terminalServer but I don't know how to access it (if that is even an
option). I am new to PowerShell so I may just be missing something simple or
I may be on the completely incorrect path.



What I would like to see is when I do a Select-Object, to have a column for
the TS Profile Path, one for the TS Home Path, and then one for the TS Home
Drive Letter.



Thanks in advance for any advice.



John


RE: PowerShell access to AD user Terminal Services attributes
/\/\o\/\/ [MVP] 12.07.2007 16:08:03
More information can be found at bottom of this post on old blog be aware
that the wrapper has changed a bit as this in a beta version, you need to add
PsObject before the invoke :

You can see this is stored in a DirectoryString named userParameters that is
not really readable , but again there are special Methods here for setting
this in the ADSI COM object you can Use with the invoke function , for a
Complete list look here on MSDN : IADsTSUserEx Property MethodsIADsTSUserEx
Property Methods

http://mow001.blogspot.com/2006/07/powershell-and-active-directory-part-3.html

"John Yarborough" wrote:

[Quoted Text]
> I've been looking at using PowerShell to help me manage my users in Active
> Directory and so far I like everything that I am seeing. I have ran into an
> issue though where I can not figure out how to access the users' Terminal
> Services attributes.
>
>
>
> Here is the command I am using to get the user information from Active
> Directory:
>
>
>
>
> Code Snippet
> Get-WMIObject -class ds_user -namespace root\directory\ldap -computername .
> | Select-Object DS_SAMAccountName
>
>
>
>
>
>
> If I pipe it to Get-Member instead of Select-Object, I see a property called
> ds_terminalServer but I don't know how to access it (if that is even an
> option). I am new to PowerShell so I may just be missing something simple or
> I may be on the completely incorrect path.
>
>
>
> What I would like to see is when I do a Select-Object, to have a column for
> the TS Profile Path, one for the TS Home Path, and then one for the TS Home
> Drive Letter.
>
>
>
> Thanks in advance for any advice.
>
>
>
> John
>
>
Re: PowerShell access to AD user Terminal Services attributes
Hal Rottenberg <halr9000[ at ]gmail.com> 13.07.2007 13:05:52
On Jul 12, 10:50 am, John Yarborough > Code Snippet
[Quoted Text]
> Get-WMIObject -class ds_user -namespace root\directory\ldap -computername .
> | Select-Object DS_SAMAccountName
>
> If I pipe it to Get-Member instead of Select-Object, I see a property called
> ds_terminalServer but I don't know how to access it (if that is even an
> option).

Note this from the select-object help file:
"If you use Select-Object to select specified properties, it copies
the values of those properties from the input objects and creates new
objects that have the specified properties and copied values."

What this means is that instead of a WMI object with certain methods
and properties, you've created a new custom object that only has the
bits you've chosen. What you need to do is perform your operations on
the WMI object itself. Easiest way to do this is like so:

# $theusers = get-wmiobject -class ds_user -namespace root\directory
\ldap

Then access the properties using the "." operator:

# $theusers.DS_SAMAccountName

Also read the help files about_objects and about_properties.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net