Bulk Add WVD users / AD export

The start of coronavirus we had to spin up WVD on azure due to not having enough personal laptops. The below script was used to export all users in our AD and import into the WVD so they could log in .

1.	 
2.	Import-Module  -name Microsoft.RDInfra.RDPowerShell
3.	Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com"
4.	 
5.	###Variables
6.	$groupName= "<enter AD group name here>"
7.	$pathToCSV="C:\Temp\"
8.	$CSVName="grouplist.csv"
9.	 
10.	###Working section of code
11.	# fetch group members, enumerate the list of users and grab the UPN, output the list to a CSV continaing only the UPN.
12.	Get-ADGroupMember -Identity $groupName | %{get-aduser $_.SamAccountName | select userPrincipalName } > $pathToCSV\$CSVName


The below will add the exported .csv file to the correct pools 

1.	$tenantName="<insert Tennant Name here>"
2.	$HostPoolName="<insert WVD pool name here>"
3.	$AppGroupName="Desktop Application Group"
4.	$PathToCSV= "C:\temp\grouplist.csv"
5.	 
6.	###Working section of code
7.	#import CSV into variable
8.	$users =( Import-Csv -Path $PathToCSV )
9.	#loop through variable to add each user in the list to the RDS host group
10.	Foreach ($user in $users ) {
11.	    Add-RdsAppGroupUser -TenantName $tenantName -HostPoolName $HostPoolName -AppGroupName $AppGroupName -UserPrincipalName $($user.userPrincipalName)
12.	    }

Leave a Reply

Your email address will not be published. Required fields are marked *