A PowerShell script to list Linux users in Active Directory: This script will search for users in your Active Directory that have the unix attributes set. The unix attributes that are most often used are uidNumber, gidNumber, unixHomeDirectory, and loginShell. The script does a search for users whose uidNumber = * meaning that it is set to something other than blank, returns the results, and displays the attributes. This is very handy since Microsoft does not display these attributes in the GUI. For more information on how to setup Active Directory users to logon to Linux, please see our index of articles related to Active Directory Authentication for Linux.
$domain = New-Object System.DirectoryServices.DirectoryEntry $searcher = New-Object System.DirectoryServices.DirectorySearcher $searcher.SearchRoot = $domain $searcher.PageSize = 1000 $searcher.Filter = "(&(objectCategory=User)(uidNumber=*))"
$proplist = ("cn","displayName","uidNumber","gidNumber","unixHomeDirectory","loginShell") foreach ($i in $propList){$prop=$searcher.PropertiesToLoad.Add($i)}
$results = $searcher.FindAll()
$results ¦ %{ $_.properties; "" }
Related Posts:
- Backup DFS Namespaces Using PowerShell
- Translate Active Directory Name Formats Using PowerShell
- List Linux Users in Active Directory Using PowerShell
- Enable Trust for Delegation in Active Directory Using PowerShell
- TCP/IP Subnet Math with PowerShell - What AD Site is that Server in?
- List Sites and Subnets in Active Directory with PowerShell
- Find Disabled Users in Active Directory with PowerShell
- List Forest-wide Group Memberships with PowerShell
- Find Old Computer Accounts in AD with PowerShell
- List SPNs in Active Directory with PowerShell
- List Domain Controllers in Active Directory
0 comments:
Post a Comment