Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,094 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
I am trying to extract the list of users along with their group, mail etc using powershell. Is there way to get this information from cmdlet?
maybe this is helpful:
Import-Module ActiveDirectory
$users = "mmouse","ppan1234"
$Table = @()
foreach ($user in $users) {
$grp = ""
$Row = [ordered]@{SamAccountName = "";DisplayName = "";Email = "";Groups = ""}
$a = Get-AdUser -Identity $user -Properties *
$groups = $a.MemberOf
foreach ($g in $groups) {
$b = Get-ADGroup $g
$grp += $b.Name + ","
}
$grp = $grp.Substring(0, $grp.Length - 1)
$row.SamAccountName = $a.SamAccountName
$row.DisplayName = $a.DisplayName
$row.Email = $a.EmailAddress
$row.Groups = $grp
$objRow = New-Object PSObject -Property $row
$Table += $objRow
}
$Table
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten