How can I get the current OU with a PowerShell login script?

Posted by Frans on Server Fault See other posts from Server Fault or by Frans
Published on 2009-09-09T11:35:51Z Indexed on 2012/12/17 17:05 UTC
Read the original article Hit count: 206

I am setting up a Terminal Server 2008 which will be used by different client organisations, each with multiple individual user accounts. I would like each client organisation to have a drive mapped to \server\clients\

Their OU name is also their client name, so I would like to be able to find their current OU and then use it for the mapping command. The OUs are hierarchicals, so it is the bottom-most OU name I need.

Example
OU:
Dedicated Clients\AjaxCorp

Should get a drive mapped to
\\server1\shares\AjaxCorp

Any suggestions on how I can get the OU? I am sure it must be easy, I just haven't figured it out...

I did find information about how to do this with VB script, but as it is a whole new environment I thought it would be nice to use PowerShell instead.

© Server Fault or respective owner

Related posts about windows-server-2008

Related posts about powershell