Header Ads

Header ADS

PS: Obtain a list of users from an AD Group, and include their Department name

Part 1 of 3

You'll find countless examples of derivatives in the web, but for the task at hand, I needed to provide a list of users who are members of a specific VDI group so we could prioritize which users to revoke access to an older VDI environment that was being phased out.

By obtaining the business units and departments, we can:
1. Understand the impact and identify potential risks associated with revoking access, such as the schedules, applications, tolerance for service interruptions, etc.
2. Tailor a message that would resonate with the department leads and representatives.
3. Consult with leadership and other stakeholders.

Script:

$ADUsers = Get-ADGroupMember -Identity "Old_VDI_Group"

foreach ($User in $ADUsers)
 {
    Get-ADUser $User -Properties Department | 
        Select-Object SAMAccountName, 
                Name, 
       Department |
  Export-Csv .\Old_VDI_Group.csv -Append
 }

No comments

Powered by Blogger.