Skip to content

Commit 71b80c4

Browse files
authored
Merge pull request #745 from glensouza/master
fix a couple of lines of code that no longer work
2 parents e4b8db8 + 7bf97cc commit 71b80c4

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

4-WebApp-your-API/4-3-AnyOrg/AppCreationScripts/Cleanup.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ Function Cleanup
4040
$tenantId = $context.TenantId
4141

4242
# Get the user running the script
43-
$currentUserPrincipalName = $context.Account
44-
$user = Get-MgUser -Filter "UserPrincipalName eq '$($context.Account)'"
43+
$me = Invoke-MgGraphRequest -Method GET https://graph.microsoft.com/v1.0/me
44+
$currentUserPrincipalName = $me.userPrincipalName
45+
$user = Get-MgUser -Filter "UserPrincipalName eq '$($currentUserPrincipalName)'"
4546

4647
# get the tenant we signed in to
4748
$Tenant = Get-MgOrganization

4-WebApp-your-API/4-3-AnyOrg/AppCreationScripts/Configure.ps1

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Function ConfigureApplications
193193

194194
if (!$azureEnvironmentName)
195195
{
196-
$azureEnvironmentName = "Global"
196+
$azureEnvironmentName = "Global" # as opposed to USGov
197197
}
198198

199199
# Connect to the Microsoft Graph API, non-interactive is not supported for the moment (Oct 2021)
@@ -209,8 +209,9 @@ Function ConfigureApplications
209209
$tenantId = $context.TenantId
210210

211211
# Get the user running the script
212-
$currentUserPrincipalName = $context.Account
213-
$user = Get-MgUser -Filter "UserPrincipalName eq '$($context.Account)'"
212+
$me = Invoke-MgGraphRequest -Method GET https://graph.microsoft.com/v1.0/me
213+
$currentUserPrincipalName = $me.userPrincipalName
214+
$user = Get-MgUser -Filter "UserPrincipalName eq '$($currentUserPrincipalName)'"
214215

215216
# get the tenant we signed in to
216217
$Tenant = Get-MgOrganization
@@ -259,7 +260,7 @@ Function ConfigureApplications
259260
$owner = Get-MgApplicationOwner -ApplicationId $currentAppObjectId
260261
if ($owner -eq $null)
261262
{
262-
New-MgApplicationOwnerByRef -ApplicationId $currentAppObjectId -BodyParameter = @{"@odata.id" = "htps://graph.microsoft.com/v1.0/directoryObjects/$user.ObjectId"}
263+
New-MgApplicationOwnerByRef -ApplicationId $currentAppObjectId -BodyParameter @{"@odata.id" = "htps://graph.microsoft.com/v1.0/directoryObjects/$($user.Id)"}
263264
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($serviceServicePrincipal.DisplayName)'"
264265
}
265266

@@ -412,7 +413,7 @@ Function ConfigureApplications
412413
$owner = Get-MgApplicationOwner -ApplicationId $currentAppObjectId
413414
if ($owner -eq $null)
414415
{
415-
New-MgApplicationOwnerByRef -ApplicationId $currentAppObjectId -BodyParameter = @{"@odata.id" = "htps://graph.microsoft.com/v1.0/directoryObjects/$user.ObjectId"}
416+
New-MgApplicationOwnerByRef -ApplicationId $currentAppObjectId -BodyParameter @{"@odata.id" = "htps://graph.microsoft.com/v1.0/directoryObjects/$($user.Id)"}
416417
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($clientServicePrincipal.DisplayName)'"
417418
}
418419

@@ -496,14 +497,14 @@ Function ConfigureApplications
496497
Write-Host " - Application 'service' publishes application permissions. Do remember to navigate to any client app(s) registration in the app portal and consent for those, (if required)" -ForegroundColor Red
497498
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
498499

499-
if($isOpenSSL -eq 'Y')
500-
{
501-
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
502-
Write-Host "You have generated certificate using OpenSSL so follow below steps: "
503-
Write-Host "Install the certificate on your system from current folder."
504-
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
505-
}
506-
Add-Content -Value "</tbody></table></body></html>" -Path createdApps.html
500+
if($isOpenSSL -eq 'Y')
501+
{
502+
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
503+
Write-Host "You have generated certificate using OpenSSL so follow below steps: "
504+
Write-Host "Install the certificate on your system from current folder."
505+
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
506+
}
507+
Add-Content -Value "</tbody></table></body></html>" -Path createdApps.html
507508
} # end of ConfigureApplications function
508509

509510
# Pre-requisites

0 commit comments

Comments
 (0)