Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

how can I get domain name attribute in get-aduser

$
0
0

Hi

I am using below script to get he all users in forest from its child domain .

Is there a way to get user belongs to which domain as I have single forest and 4 child domains.

If not , then how can I remove userPrincipalName first part before @ sign . . Can i get only domain name ?

 

Import-Module ActiveDirectory

 $domains= (Get-ADForest).domains

 $Outfile = "D:\script\SIPuserdetails.csv"

 

foreach ($domain in $domains)

{

   Get-ADUser -Filter {(msRTCSIP-UserEnabled -eq $True) -and (enabled -eq $True)} -Server $domain -Properties * | select name,samaccountname,msRTCSIP-PrimaryUserAddress,msRTCSIP-UserEnabled,@{n="domain Name"; e={$_.userPrincipalName}}

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles