forked from tomwechsler/Azure_PowerShell_Administration
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCreate_management_groups_organization_management.ps1
More file actions
36 lines (25 loc) · 1.18 KB
/
Create_management_groups_organization_management.ps1
File metadata and controls
36 lines (25 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Set-Location c:\
Clear-Host
Install-Module -Name Az -Force -AllowClobber -Verbose
#Log into Azure
Connect-AzAccount
#Select the correct subscription
Get-AzSubscription -SubscriptionName "MSDN Platforms" | Select-AzSubscription
#Create a management group
New-AzManagementGroup -GroupName 'Contoso'
#If you want the management group to show a different name within the Azure portal, add the DisplayName parameter
New-AzManagementGroup -GroupName 'TomRocks' -DisplayName 'TomRocks Group'
#To specify a different management group as the parent, use the ParentId parameter
$parentGroup = Get-AzManagementGroup -GroupName TomRocks
New-AzManagementGroup -GroupName 'TomRocksSubGroup' -ParentId $parentGroup.id
#Change the name
Update-AzManagementGroup -GroupName 'TomRocks' -DisplayName 'Wechsler Group'
#To delete management group
Remove-AzManagementGroup -GroupName 'TomRocks'
#To retrieve all groups
Get-AzManagementGroup
#For a single management group's information
Get-AzManagementGroup -GroupName 'Contoso'
#To return a specific management group and all the levels of the hierarchy under it
$response = Get-AzManagementGroup -GroupName TestGroupParent -Expand -Recurse
$response