You can do this with 3 scripts
- Script1: Create the groups (using the first column of the csv)
- Script2 (if user not exists already): Create the users (using the second column of the csv)
- Script3: Add user to group( using the both column of the csv)
Or with one script with some more logic in the script:
- Use both columns of csv and walk trough
- Create group if not exists
- Create user if not exists
- Add user to group
The following cmdlets will do the job:
https://learn.microsoft.com/en-us/powershell/module/azuread/new-azureaduser?view=azureadps-2.0
https://learn.microsoft.com/en-us/powershell/module/azuread/new-azureadgroup?view=azureadps-2.0
https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0
https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureadgroup?view=azureadps-2.0
https://learn.microsoft.com/en-us/powershell/module/azuread/add-azureadgroupmember?view=azureadps-2.0
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten