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}}
}