microsoft-365-docs
microsoft-365-docs copied to clipboard
Block Group Creation script doesn't work
The block group creation script here doesn't work
https://docs.microsoft.com/en-us/microsoft-365/solutions/manage-creation-of-groups?view=o365-worldwide
I attempted to install AzureADPreview, then attempted to run the script but it came back all red:
Get-AzureADDirectorySetting : The term 'Get-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:6 char:22
- $settingsObjectID = (Get-AzureADDirectorySetting | Where-object -Prop ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-AzureADDirectorySetting:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
Get-AzureADDirectorySettingTemplate : The term 'Get-AzureADDirectorySettingTemplate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:9 char:17
-
$template = Get-AzureADDirectorySettingTemplate | Where-object {$ ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-AzureADDirectorySettingTemplate:String) [], CommandNotFoundExceptio n
- FullyQualifiedErrorId : CommandNotFoundException
You cannot call a method on a null-valued expression. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:10 char:5
-
$settingsCopy = $template.CreateDirectorySetting() -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
New-AzureADDirectorySetting : The term 'New-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:11 char:5
-
New-AzureADDirectorySetting -DirectorySetting $settingsCopy -
~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (New-AzureADDirectorySetting:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
Get-AzureADDirectorySetting : The term 'Get-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:12 char:26
-
$settingsObjectID = (Get-AzureADDirectorySetting | Where-object - ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-AzureADDirectorySetting:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
Get-AzureADDirectorySetting : The term 'Get-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:15 char:17
- $settingsCopy = Get-AzureADDirectorySetting -Id $settingsObjectID
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-AzureADDirectorySetting:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
Cannot index into a null array. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:16 char:1
- $settingsCopy["EnableGroupCreation"] = $AllowGroupCreation
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray
Cannot index into a null array. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:20 char:3
- $settingsCopy["GroupCreationAllowedGroupId"] = (Get-AzureADGroup -S ...
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray
Set-AzureADDirectorySetting : The term 'Set-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:24 char:1
- Set-AzureADDirectorySetting -Id $settingsObjectID -DirectorySetting $ ...
-
+ CategoryInfo : ObjectNotFound: (Set-AzureADDirectorySetting:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Get-AzureADDirectorySetting : The term 'Get-AzureADDirectorySetting' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\Tech\VitalNetix\VitalNetix Team Site - Documents\Scripts\PowershellRepo\NPWA-BlockGroupCreation365.ps1:26 char:2
- (Get-AzureADDirectorySetting -Id $settingsObjectID).Values
-
+ CategoryInfo : ObjectNotFound: (Get-AzureADDirectorySetting:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 445c0a2e-1a22-d90f-0c73-0edf34f2b99a
- Version Independent ID: d534ac69-134d-0198-fcb9-e19d1ed44d4b
- Content: Manage who can create Microsoft 365 Groups
- Content Source: microsoft-365/solutions/manage-creation-of-groups.md
- Service: o365-administration
- GitHub Login: @MikePlumleyMSFT
- Microsoft Alias: mikeplum
@VNJoe Thank you for your feedback. I tested the cmdlets on a couple of tenants and they seem to work properly.

If this continues to be a problem, I'd recommend you to contact Microsoft support via the need help section on the admin center, so that a support engineer can help you fix this.
Hope this helps!
Thanks Sri
@msbemba Thank you very much for the contribution and sharing this explanation. @VNJoe Hope this comment is helpful for you. Considering the nature of the issue, as advised, please open a service ticket in your tenant and follow with them for the resolution. We proceed to close it as here we are limited to documentation fixes and improvements only. We will be very happy if you can share the outcome or resolution with us if you see documentation update is required. We will certainly update this documentation with that valuable information. Thanks again, for taking out some time to open the issue. Appreciate and encourage you to do the same in future also.