Forum Discussion

Yallos's avatar
Yallos
Copper Contributor
Jun 17, 2022
Solved

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

 

 

  • Yallos 

    The ForEach needs a small correction
    You wrote

    ForEach{Set-AzureADGroup -ObjectID $.objectid -Displayname $.displayname}

    The $.ObjectID should be $_.ObjectID

    Also the $.Displayname should be $_.DisplayName

2 Replies

  • farismalaeb's avatar
    farismalaeb
    Steel Contributor

    Yallos 

    The ForEach needs a small correction
    You wrote

    ForEach{Set-AzureADGroup -ObjectID $.objectid -Displayname $.displayname}

    The $.ObjectID should be $_.ObjectID

    Also the $.Displayname should be $_.DisplayName

    • Yallos's avatar
      Yallos
      Copper Contributor

      farismalaeb Thanks a lot for your input. One of those days you know.
      Issue resolved

       

      Import-Csv -Path C:\Users\Prince\Downloads\"exportGroup_2022-6-15.csv"| ForEach{Set-AzureADGroup -ObjectID $_.Objectid -Displayname $_.displayname}

Resources