Link to home
Start Free TrialLog in
Avatar of davesnb
davesnbFlag for Canada

asked on

Powershell converting noteproperty curly brace member

Hello EE,

I am creating a script to pull some active directory information as an html report for compliance reasons . I have one line of code that I have been struggling with .

[array]$ClientUserRoles = get-qaduser -SizeLimit 50000 |where { $_.accountisdisabled -match "False" -and $_.ParentContainer  -match "domain.ca/ClientAccts"  } | select memberof,name |sort memberof 

Open in new window


The issue is the "memberof" member is a curly bracket noteproperty , so when I convert this to html it reads "System.String[]" . So how would I get only the "CN=" values as a string?

ypeName: Selected.Quest.ActiveRoles.ArsPowerShellSnapIn.Data.ArsUserObject

Name        MemberType   Definition                              
----        ----------   ----------                              
Equals      Method       bool Equals(System.Object obj)          
GetHashCode Method       int GetHashCode()                       
GetType     Method       type GetType()                          
ToString    Method       string ToString()                       
MemberOf    NoteProperty System.String[] MemberOf=System.String[]
Name        NoteProperty System.String Name=Foglight             

Open in new window


MemberOf : {CN=ErnestAD,OU=Ernest,OU=ClientAccts,DC=domain,DC=ca, CN=ErnestGGTrain,OU=Ernest,OU=ClientAccts,DC=domain,DC=ca, 
           CN=ErnestGGProd,OU=Ernest,OU=ClientAccts,DC=domain,DC=ca, CN=ErnestGlobal,OU=Ernest,OU=ClientAccts,DC=domain,DC=ca}
Name     : ernest40

Open in new window

Avatar of SubSun
SubSun
Flag of India image

Use..
[array]$ClientUserRoles = get-qaduser -SizeLimit 50000 |where { $_.accountisdisabled -match "False" -and $_.ParentContainer  -match "domain.ca/ClientAccts"  } | select {$_.memberof},name |sort $_.memberof

Open in new window

Or
[array]$ClientUserRoles = get-qaduser -SizeLimit 50000 |where { $_.accountisdisabled -match "False" -and $_.ParentContainer  -match "domain.ca/ClientAccts"  } | select @{N="memberof";E={$_.memberof}},name |sort memberof 

Open in new window

Avatar of davesnb

ASKER

Ok the second block of code works but , how do I only select the " CN=" ? Ie ,  I only wish to gather the container ( group designation) ?

[array]$ClientUserRoles = get-qaduser -SizeLimit 500 |where { $_.accountisdisabled -match "False" -and $_.ParentContainer  -match "intelisys.ca/ClientAccts"  } | select @{N="memberof";E={$_.memberof}},name |sort memberof 
$ClientUserRoles = $ClientUserRoles | somestuff here to gather only the groups info

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davesnb

ASKER

U da man Subsan ..U da man!