Hi @mark terry
Based on the error you provided; it appears that the particular website is currently unavailable. I will follow up with my internal team. As Andy mentioned, you can refer to the document below to convert your Azure AD commands to Microsoft Graph API commands, such as MgGraph API module. To update your script to utilize the Microsoft Graph PowerShell cmdlets, please follow the structure outlined below.
For further information, please refer to the link provided.
https://learn.microsoft.com/en-us/powershell/microsoftgraph/azuread-msoline-cmdlet-map?view=graph-powershell-1.0&pivots=azure-ad-powershell
$GroupName = "Test User Group"
$CSVFile = "D:\Temp\Users.csv"
#Get users to import from a CSV File
$Users = Import-Csv -Path $CSVFile
#Connect to Azure AD
Connect-MgGraph
#Get the Group
$Group = Get-MgGroup-Filter "SecurityEnabled eq true and MailEnabled eq false and Displayname eq '$GroupName'"
#Get Exisiting Members of the Group
$GroupMembers = Get-MgGroupMember -GroupId $Group.Id -All | Select -ExpandProperty UserPrincipalName
# Add Each user to the Security group
ForEach ($User in $Users) {
# Check if the group has the member already
if ($GroupMembers -contains $User.userprincipalname) {
Write-Host "User '$($User.userprincipalname)' is already a Member of the Group!" -ForegroundColor Yellow
} else {
$UserObj = Get-MgUser -UserId $User.userprincipalname
New-MgGroupMember -GroupId $Group.Id -UserId $UserObj.Id
Write-Host "User '$($User.userprincipalname)' has been added to the Group!"
}
}
Hope this helps. Do let us know if you any further queries.
Best Regards,
Harshitha Eligeti.