Forum Discussion
Yallos
Jun 17, 2022Copper Contributor
How to Bulk rename Security groups on AAD
Hi Team,
I'm trying to rename over 100 Azure security groups using PowerShell but I just can't get the script to work without errors. I want to add "NG" to the output of the GetAzADGroup command
# Get the group that we want to modify.
$Group = Get-AzADGroup -DisplayNameStartsWith 'test'
#Next line is to Import Csv with the new group name eg "NG-Test1, NG-Test2" etc #
Import-Csv -Path C:\Users\Prince\Downloads\exportGroup_2022-6-15.csv | ForEach{Set-AzureADGroup -ObjectID $.objectid -Displayname $.displayname}
I run into the following error "Set-AzureADGroup : Error occurred while executing SetGroup"
I'll appreciate any help or pointers to resolve this. Thanks in advance
The ForEach needs a small correction
You wroteForEach{Set-AzureADGroup -ObjectID $.objectid -Displayname $.displayname}
The $.ObjectID should be $_.ObjectID
Also the $.Displayname should be $_.DisplayName
2 Replies
Sort By
- farismalaebSteel Contributor
The ForEach needs a small correction
You wroteForEach{Set-AzureADGroup -ObjectID $.objectid -Displayname $.displayname}
The $.ObjectID should be $_.ObjectID
Also the $.Displayname should be $_.DisplayName
- YallosCopper Contributor
farismalaeb Thanks a lot for your input. One of those days you know.
Issue resolvedImport-Csv -Path C:\Users\Prince\Downloads\"exportGroup_2022-6-15.csv"| ForEach{Set-AzureADGroup -ObjectID $_.Objectid -Displayname $_.displayname}