Skip to content

Commit 311f837

Browse files
committed
fix script not replacing group ids
1 parent 6a1845c commit 311f837

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

5-AccessControl/2-call-api-groups/AppCreationScripts/Cleanup.ps1

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,6 @@ if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Groups")) {
1313

1414
Import-Module Microsoft.Graph.Groups
1515

16-
<#.Description
17-
This function creates a new Azure AD Security Group with provided values
18-
#>
19-
Function CreateSecurityGroup([string] $name, [string] $description)
20-
{
21-
Write-Host "Creating a security group by the name '$name'."
22-
$newGroup = New-MgGroup -Description $description -DisplayName $name -MailEnabled:$false -SecurityEnabled:$true -MailNickName $name
23-
return Get-MgGroup -Filter "DisplayName eq '$name'"
24-
}
25-
26-
<#.Description
27-
This function first checks and then creates a new Azure AD Security Group with provided values, if required
28-
#>
29-
Function CreateIfNotExistsSecurityGroup([string] $name, [string] $description, [switch] $promptBeforeCreate)
30-
{
31-
32-
# check if Group exists
33-
$group = Get-MgGroup -Filter "DisplayName eq '$name'"
34-
35-
if( $group -eq $null)
36-
{
37-
if ($promptBeforeCreate)
38-
{
39-
$confirmation = Read-Host "Proceed to create a new security group named '$name' in the tenant ? (Y/N)"
40-
41-
if($confirmation -eq 'y')
42-
{
43-
$group = CreateSecurityGroup -name $name -description $description
44-
}
45-
}
46-
else
47-
{
48-
Write-Host "No Security Group created!"
49-
}
50-
}
51-
52-
return $group
53-
}
54-
5516
<#.Description
5617
This function first checks and then deletes an existing Azure AD Security Group, if required
5718
#>

5-AccessControl/2-call-api-groups/AppCreationScripts/Configure.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,9 @@ Function ConfigureApplications
381381

382382
# rename the user_impersonation scope if it exists to match the readme steps or add a new scope
383383

384-
# delete default scope i.e. User_impersonation
385-
# Alex: the scope deletion doesn't work - see open issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/1054
384+
# delete default scope i.e. user_impersonation
386385
$scopes = New-Object System.Collections.Generic.List[Microsoft.Graph.PowerShell.Models.MicrosoftGraphPermissionScope]
387-
$scope = $clientAadApplication.Api.Oauth2PermissionScopes | Where-Object { $_.Value -eq "User_impersonation" }
386+
$scope = $clientAadApplication.Api.Oauth2PermissionScopes | Where-Object { $_.Value -eq "user_impersonation" }
388387

389388
if($scope -ne $null)
390389
{
@@ -447,12 +446,11 @@ Function ConfigureApplications
447446

448447
# Create any security groups that this app requires.
449448

450-
$newGroup = CreateIfNotExistsSecurityGroup -name 'GroupAdmin' -description 'Admin Security Group' -promptBeforeCreate 'Y'
449+
$GroupAdmin = CreateIfNotExistsSecurityGroup -name 'GroupAdmin' -description 'Admin Security Group' -promptBeforeCreate 'Y'
451450
Write-Host "group id of 'GroupAdmin'" -> $newGroup.Id -ForegroundColor Green
452451

453-
$newGroup = CreateIfNotExistsSecurityGroup -name 'GroupMember' -description 'User Security Group' -promptBeforeCreate 'Y'
454-
Write-Host "group id of 'GroupMember'" -> $newGroup.Id -ForegroundColor Green
455-
Write-Host "Don't forget to assign the users you wish to work with to the newly created security groups !" -ForegroundColor Red
452+
$GroupMember = CreateIfNotExistsSecurityGroup -name 'GroupMember' -description 'User Security Group' -promptBeforeCreate 'Y'
453+
Write-Host "group id of 'GroupMember'" -> $newGroup.Id -ForegroundColor Green
456454

457455
# print the registered app portal URL for any further navigation
458456
Write-Host "Successfully registered and configured that app registration for 'msal-angular-app' at `n $clientPortalUrl" -ForegroundColor Red
@@ -473,7 +471,7 @@ Function ConfigureApplications
473471
# $configFile = $pwd.Path + "\..\SPA\src\app\auth-config.ts"
474472
$configFile = $(Resolve-Path ($pwd.Path + "\..\SPA\src\app\auth-config.ts"))
475473

476-
$dictionary = @{ "Enter_the_Application_Id_Here" = $clientAadApplication.AppId;"Enter_the_Tenant_Info_Here" = $tenantId;"Enter_the_Web_Api_Application_Id_Here" = $clientAadApplication.AppId;"Enter the object ID for GroupAdmin group copied from Azure Portal" = $GroupAdmin.objectId;"Enter the object ID for GroupMember group copied from Azure Portal" = $GroupMember.objectId };
474+
$dictionary = @{ "Enter_the_Application_Id_Here" = $clientAadApplication.AppId;"Enter_the_Tenant_Info_Here" = $tenantId;"Enter_the_Web_Api_Application_Id_Here" = $clientAadApplication.AppId;"Enter the object ID for GroupAdmin group copied from Azure Portal" = $GroupAdmin.Id;"Enter the object ID for GroupMember group copied from Azure Portal" = $GroupMember.Id };
477475

478476
Write-Host "Updating the sample config '$configFile' with the following config values:" -ForegroundColor Green
479477
$dictionary

5-AccessControl/2-call-api-groups/AppCreationScripts/sample.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@
9494
},
9595
{
9696
"key": "Enter the object ID for GroupAdmin group copied from Azure Portal",
97-
"value": "$GroupAdmin.objectId"
97+
"value": "$GroupAdmin.Id"
9898
},
9999
{
100100
"key": "Enter the object ID for GroupMember group copied from Azure Portal",
101-
"value": "$GroupMember.objectId"
101+
"value": "$GroupMember.Id"
102102
}
103103
]
104104
},
@@ -121,11 +121,11 @@
121121
},
122122
{
123123
"key": "Enter the object ID for GroupAdmin group copied from Azure Portal",
124-
"value": "$GroupAdmin.objectId"
124+
"value": "$GroupAdmin.Id"
125125
},
126126
{
127127
"key": "Enter the object ID for GroupMember group copied from Azure Portal",
128-
"value": "$GroupMember.objectId"
128+
"value": "$GroupMember.Id"
129129
}
130130
]
131131
}

0 commit comments

Comments
 (0)