Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of Contents

Table of Contents

Script Information

The `t is used for a Tab Delimiter

The `r`n is used for Carriage Return within the script

Script Code

Output looks like this: 

*Table of Contents* {toc} h1. Script Information The `t is used for a Tab Delimiter The `r`n is used for Carriage Return within the script h1. Script Code Output looks like this:
Code Block
languagepowershell
$strFilter = "(&(objectCategory=User))" 
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Company-Users,OU=Company-Org,DC=Domain,DC=local") 
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher 
$objSearcher.SearchRoot = $objDomain 
$objSearcher.PageSize = 1000 
$objSearcher.Filter = $strFilter 
$objSearcher.SearchScope = "Subtree" 
$colProplist = "name", "jobTitle", "department", "manager", "memberof" 

 foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)} 

 $colResults = $objSearcher.FindAll() 

 foreach ($objResult in $colResults) 
{$objItem = $objResult.Properties 
"Name:`t`t" + $objItem.name 
"Title:`t`t" + $objItem.jobTitle 
"Department:`t" + $objItem.department 
"Manager:`t" + $objItem.manager -replace "CN=", "" -replace ",DC=Domain,DC=local", "" 
"Member of: `r`n" + $objItem.memberof -replace "CN=", "" -replace ",DC=Domain,DC=local", "`r`n" 
}
Wiki Markup

Name:Adam

...

Melong

...

Title:Super

...

Genius

...

Department:Professional

...

Services

...

Manager:Manager

...

Name

...

Member

...

of:

...

~Company

...

~Professional_Services

...

Ottawa

...

Tech

...

All

...

Everybody

...

UserGroup

...