Forum Discussion
midiman810new
Apr 09, 2026Brass Contributor
Powershell Entra and General Forum Layout Questions
Hello, I am returning to PowerShell, and it seems a lot has changed. I need to create some Security Groups in MS Entra and would like to know the best way to do so. I have a .csv file for the g...
sdtslmn
May 02, 2026MCT
for the first question we may have an answer but for the second one you need to scroll
first one it is recommended to use if you are just touching EntraID use Microsoft.Entra module
but if you want to touch multiple systems like entra, SharePoint, teams etc. use Microsoft.Graph module
if i assume this is just for EntraID
first install module
Install-Module Microsoft.Entra -Scope CurrentUser
then you may need something similar to the following
if you have columns like
DisplayName,Description,MailNick,Owner
Connect-Entra -Scopes 'Group.ReadWrite.All','Group.Create','User.Read.All'
$groups = Import-Csv -Path 'Groups.csv'
foreach ($g in $groups) {
$newGroup = New-EntraGroup `
-DisplayName $g.DisplayName `
-Description $g.Description `
-MailNick $g.MailNickname `
-MailEnabled $false `
-SecurityEnabled $true
Write-Host "Created: $($newGroup.DisplayName)" -ForegroundColor Green
if ($g.Owner) {
$owner = Get-EntraUser -UserId $g.Owner
Add-EntraGroupOwner -GroupId $newGroup.Id -OwnerId $owner.Id
}
}
Disconnect-Entra