Skip to content

Commit 8fbff94

Browse files
committed
TenantID case sensitivity
1 parent c50af30 commit 8fbff94

17 files changed

+30
-30
lines changed

Cleanup_OldAuditLogs/run.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
param($Timer)
33

44
try {
5-
$Tenants = Get-Tenants -IncludeAll | Where-Object { $_.customerId -ne $env:TenantId -and $_.Excluded -eq $false }
5+
$Tenants = Get-Tenants -IncludeAll | Where-Object { $_.customerId -ne $env:TenantID -and $_.Excluded -eq $false }
66
$Tenants | ForEach-Object {
77
Remove-CIPPGraphSubscription -cleanup $true -TenantFilter $_.defaultDomainName
88
}
9-
} catch {}
9+
} catch {}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecPartnerWebhook.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function Invoke-ExecPartnerWebhook {
3434
'CreateSubscription' {
3535
$BaseURL = ([System.Uri]$Request.Headers.'x-ms-original-url').Host
3636
$Webhook = @{
37-
TenantFilter = $env:TenantId
37+
TenantFilter = $env:TenantID
3838
PartnerCenter = $true
3939
BaseURL = $BaseURL
4040
EventType = $Request.Body.EventType
@@ -74,4 +74,4 @@ function Invoke-ExecPartnerWebhook {
7474
StatusCode = [System.Net.HttpStatusCode]::OK
7575
Body = $Body
7676
}
77-
}
77+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecServicePrincipals.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Invoke-ExecServicePrincipals {
88
[CmdletBinding()]
99
param($Request, $TriggerMetadata)
1010

11-
$TenantFilter = $env:TenantId
11+
$TenantFilter = $env:TenantID
1212

1313
$Success = $true
1414

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecAccessChecks.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function Invoke-ExecAccessChecks {
1717
# Write to the Azure Functions log stream.
1818
Write-Host 'PowerShell HTTP trigger function processed a request.'
1919
if ($Request.Query.Permissions -eq 'true') {
20-
$Results = Test-CIPPAccessPermissions -tenantfilter $ENV:tenantid -APIName $APINAME -ExecutingUser $Request.Headers.'x-ms-client-principal'
20+
$Results = Test-CIPPAccessPermissions -tenantfilter $ENV:TenantID -APIName $APINAME -ExecutingUser $Request.Headers.'x-ms-client-principal'
2121
}
2222

2323
if ($Request.Query.Tenants -eq 'true') {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Function Invoke-ExecCPVPermissions {
3131
if ($TenantFilter -ne 'PartnerTenant') {
3232
Set-CIPPCPVConsent @CPVConsentParams
3333
} else {
34-
$TenantFilter = $env:TenantId
34+
$TenantFilter = $env:TenantID
3535
}
3636
Add-CIPPApplicationPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter
3737
Add-CIPPDelegatedPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecSAMSetup.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Function Invoke-ExecSAMSetup {
8282
if ($Request.Query.code) {
8383
try {
8484
$TenantId = $Rows.tenantid
85-
if (!$TenantId) { $TenantId = $ENV:TenantId }
85+
if (!$TenantId) { $TenantId = $ENV:TenantID }
8686
$AppID = $Rows.appid
8787
if (!$AppID) { $appid = $ENV:ApplicationID }
8888
$URL = ($Request.headers.'x-ms-original-url').split('?') | Select-Object -First 1

Modules/CIPPCore/Public/Entrypoints/Invoke-ListFunctionParameters.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function Invoke-ListFunctionParameters {
3333
if ($Module -eq 'ExchangeOnlineManagement') {
3434
$ExoRequest = @{
3535
AvailableCmdlets = $true
36-
tenantid = $env:TenantId
36+
tenantid = $env:TenantID
3737
NoAuthCheck = $true
3838
}
3939
if ($Request.Query.Compliance -eq $true) {

Modules/CIPPCore/Public/Entrypoints/Invoke-ListInactiveAccounts.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Function Invoke-ListInactiveAccounts {
2121
$TenantFilter = $Request.Query.TenantFilter
2222
if ($TenantFilter -eq 'AllTenants') { $TenantFilter = (get-tenants).customerId }
2323
try {
24-
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/managedTenants/inactiveUsers?`$count=true" -tenantid $env:TenantId | Where-Object { $_.tenantId -in $TenantFilter }
24+
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/managedTenants/inactiveUsers?`$count=true" -tenantid $env:TenantID | Where-Object { $_.tenantId -in $TenantFilter }
2525
$StatusCode = [HttpStatusCode]::OK
2626
} catch {
2727
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message

Modules/CIPPCore/Public/GraphHelper/Get-AuthorisedRequest.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ function Get-AuthorisedRequest {
1010
[string]$Uri
1111
)
1212
if (!$TenantID) {
13-
$TenantID = $env:TenantId
13+
$TenantID = $env:TenantID
1414
}
1515
if ($Uri -like 'https://graph.microsoft.com/beta/contracts*' -or $Uri -like '*/customers/*' -or $Uri -eq 'https://graph.microsoft.com/v1.0/me/sendMail' -or $Uri -like '*/tenantRelationships/*') {
1616
return $true
1717
}
1818
$Tenants = Get-Tenants -IncludeErrors
1919
$SkipList = Get-Tenants -SkipList
20-
if (($env:PartnerTenantAvailable -eq $true -and $SkipList.customerId -notcontains $TenantID -and $SkipList.defaultDomainName -notcontains $TenantID) -or (($Tenants.customerId -contains $TenantID -or $Tenants.defaultDomainName -contains $TenantID) -and $TenantID -ne $env:TenantId)) {
20+
if (($env:PartnerTenantAvailable -eq $true -and $SkipList.customerId -notcontains $TenantID -and $SkipList.defaultDomainName -notcontains $TenantID) -or (($Tenants.customerId -contains $TenantID -or $Tenants.defaultDomainName -contains $TenantID) -and $TenantID -ne $env:TenantID)) {
2121
return $true
2222
} else {
2323
return $false

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function Get-GraphRequestList {
4848
#>
4949
[CmdletBinding()]
5050
Param(
51-
[string]$TenantFilter = $env:TenantId,
51+
[string]$TenantFilter = $env:TenantID,
5252
[Parameter(Mandatory = $true)]
5353
[string]$Endpoint,
5454
[hashtable]$Parameters = @{},
@@ -294,7 +294,7 @@ function Get-GraphRequestList {
294294
method = 'GET'
295295
}
296296
}
297-
$TenantInfo = New-GraphBulkRequest -Requests @($ReverseLookupRequests) -tenantid $env:TenantId -NoAuthCheck $true -asapp $true
297+
$TenantInfo = New-GraphBulkRequest -Requests @($ReverseLookupRequests) -tenantid $env:TenantID -NoAuthCheck $true -asapp $true
298298

299299
$GraphRequestResults | Select-Object @{n = 'TenantInfo'; e = { Get-GraphBulkResultByID -Results @($TenantInfo) -ID $_.$ReverseTenantLookupProperty } }, *
300300

Modules/CIPPCore/Public/New-CIPPAPIConfig.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function New-CIPPAPIConfig {
3939
$currentSettings.properties.identityProviders.azureActiveDirectory = @{
4040
registration = @{
4141
clientId = $APIApp.appId
42-
openIdIssuer = "https://sts.windows.net/$($ENV:TenantId)/v2.0"
42+
openIdIssuer = "https://sts.windows.net/$($ENV:TenantID)/v2.0"
4343
}
4444
validation = @{
4545
allowedAudiences = @("api://$($APIApp.appId)")

Modules/CIPPCore/Public/New-CIPPApplicationCopy.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ function New-CIPPApplicationCopy {
66
)
77
$CurrentInfo = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/servicePrincipals?$top=999' -tenantid $env:TenantID -NoAuthCheck $true
88
try {
9-
$ExistingApp = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/Applications(appId='$($app)')" -tenantid $ENV:tenantid -NoAuthCheck $true
9+
$ExistingApp = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/Applications(appId='$($app)')" -tenantid $ENV:TenantID -NoAuthCheck $true
1010
$Type = 'Application'
1111
} catch {
12-
$ExistingApp = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($app)')/oauth2PermissionGrants" -tenantid $ENV:tenantid -NoAuthCheck $true
13-
$ExistingAppRoleAssignments = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($app)')/appRoleAssignments" -tenantid $ENV:tenantid -NoAuthCheck $true
12+
$ExistingApp = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($app)')/oauth2PermissionGrants" -tenantid $ENV:TenantID -NoAuthCheck $true
13+
$ExistingAppRoleAssignments = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($app)')/appRoleAssignments" -tenantid $ENV:TenantID -NoAuthCheck $true
1414
$Type = 'ServicePrincipal'
1515
}
1616
if (!$ExistingApp) {

Modules/CIPPCore/Public/Set-CIPPGDAPAutoExtend.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ function Set-CIPPGDAPAutoExtend {
88
)
99

1010
$ReturnedData = if ($All -eq $true) {
11-
$Relationships = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships' -tenantid $env:tenantid -NoAuthCheck $true | Where-Object -Property autoExtendDuration -EQ 'PT0S'
11+
$Relationships = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships' -tenantid $env:TenantID -NoAuthCheck $true | Where-Object -Property autoExtendDuration -EQ 'PT0S'
1212
foreach ($Relation in $Relationships) {
1313
try {
1414
$AddedHeader = @{'If-Match' = $Relation.'@odata.etag' }
1515
if ($PSCmdlet.ShouldProcess($Relation.id, "Set auto renew for $($Relation.customer.displayName)")) {
16-
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships/$($Relation.id)" -tenantid $env:tenantid -type PATCH -body '{"autoExtendDuration":"P180D"}' -Verbose -NoAuthCheck $true -AddedHeaders $AddedHeader
16+
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships/$($Relation.id)" -tenantid $env:TenantID -type PATCH -body '{"autoExtendDuration":"P180D"}' -Verbose -NoAuthCheck $true -AddedHeaders $AddedHeader
1717
Write-LogMessage -user $ExecutingUser -API $APIName -message "Successfully set auto renew for tenant $($Relation.customer.displayName) with ID $($RelationShipid)" -Sev 'Info'
1818
@("Successfully set auto renew for tenant $($Relation.customer.displayName) with ID $($Relation.id)" )
1919
}
@@ -25,10 +25,10 @@ function Set-CIPPGDAPAutoExtend {
2525
}
2626
} else {
2727
try {
28-
$Relationship = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships' -tenantid $env:tenantid -NoAuthCheck $true | Where-Object -Property id -EQ $RelationShipid
28+
$Relationship = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships' -tenantid $env:TenantID -NoAuthCheck $true | Where-Object -Property id -EQ $RelationShipid
2929
$AddedHeader = @{'If-Match' = $Relationship.'@odata.etag' }
3030
if ($PSCmdlet.ShouldProcess($RelationShipid, "Set auto renew for $($Relationship.customer.displayName)")) {
31-
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships/$($RelationShipid)" -tenantid $env:tenantid -type PATCH -body '{"autoExtendDuration":"P180D"}' -Verbose -NoAuthCheck $true -AddedHeaders $AddedHeader
31+
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships/$($RelationShipid)" -tenantid $env:TenantID -type PATCH -body '{"autoExtendDuration":"P180D"}' -Verbose -NoAuthCheck $true -AddedHeaders $AddedHeader
3232
write-LogMessage -user $ExecutingUser -API $APIName -message "Successfully set auto renew for tenant $($Relationship.customer.displayName) with ID $($RelationShipid)" -Sev 'Info'
3333
@("Successfully set auto renew for tenant $($Relationship.customer.displayName) with ID $($RelationShipid)" )
3434
}

Modules/CIPPCore/Public/Test-CIPPAccessTenant.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Test-CIPPAccessTenant {
4242
#Write-Host ($GDAPRolesGraph.body.value | ConvertTo-Json -Depth 10)
4343
foreach ($RoleId in $ExpectedRoles) {
4444
$GraphRole = $GDAPRolesGraph.body.value | Where-Object -Property roleDefinitionId -EQ $RoleId.Id
45-
$Role = $GraphRole.principal | Where-Object -Property organizationId -EQ $ENV:tenantid
45+
$Role = $GraphRole.principal | Where-Object -Property organizationId -EQ $ENV:TenantID
4646

4747
if (!$Role) {
4848
$MissingRoles.Add(

Modules/CIPPCore/Public/Webhooks/Get-CIPPAuditLogContentBundles.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function Get-CIPPAuditLogContentBundles {
5151

5252
$Parameters = @{
5353
'contentType' = $ContentType
54-
'PublisherIdentifier' = $env:TenantId
54+
'PublisherIdentifier' = $env:TenantID
5555
}
5656

5757
if (!$ShowAll.IsPresent) {

Modules/CIPPCore/Public/Webhooks/New-CIPPGraphSubscription.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function New-CIPPGraphSubscription {
4747
}
4848
Write-Host "Creating webhook subscription for $EventType"
4949

50-
$AuditLog = New-GraphPOSTRequest -type POST -uri "https://manage.office.com/api/v1.0/$($TenantFilter)/activity/feed/subscriptions/start?contentType=$EventType&PublisherIdentifier=$($env:TenantId)" -tenantid $TenantFilter -scope 'https://manage.office.com/.default' -body '{}' -verbose
50+
$AuditLog = New-GraphPOSTRequest -type POST -uri "https://manage.office.com/api/v1.0/$($TenantFilter)/activity/feed/subscriptions/start?contentType=$EventType&PublisherIdentifier=$($env:TenantID)" -tenantid $TenantFilter -scope 'https://manage.office.com/.default' -body '{}' -verbose
5151
Write-LogMessage -user $ExecutingUser -API $APIName -message "Created Webhook subscription for $($TenantFilter) for the log $($EventType)" -Sev 'Info' -tenant $TenantFilter
5252
return @{ Success = $true; message = "Created Webhook subscription for $($TenantFilter) for the log $($EventType)" }
5353
} else {
@@ -80,9 +80,9 @@ function New-CIPPGraphSubscription {
8080
}
8181
}
8282
} elseif ($PartnerCenter.IsPresent) {
83-
$WebhookFilter = "PartitionKey eq '$($env:TenantId)'"
83+
$WebhookFilter = "PartitionKey eq '$($env:TenantID)'"
8484
$ExistingWebhooks = Get-CIPPAzDataTableEntity @WebhookTable -Filter $WebhookFilter
85-
$CIPPID = $env:TenantId
85+
$CIPPID = $env:TenantID
8686
$MatchedWebhook = $ExistingWebhooks | Where-Object { $_.Resource -eq 'PartnerCenter' -and $_.RowKey -eq $CIPPID }
8787

8888
# Required event types
@@ -107,7 +107,7 @@ function New-CIPPGraphSubscription {
107107
try {
108108
$Uri = 'https://api.partnercenter.microsoft.com/webhooks/v1/registration'
109109
try {
110-
$Existing = New-GraphGetRequest -NoAuthCheck $true -uri $Uri -tenantid $env:TenantId -scope 'https://api.partnercenter.microsoft.com/.default'
110+
$Existing = New-GraphGetRequest -NoAuthCheck $true -uri $Uri -tenantid $env:TenantID -scope 'https://api.partnercenter.microsoft.com/.default'
111111
} catch { $Existing = $false }
112112
if (!$Existing -or $Existing.webhookUrl -ne $MatchedWebhook.WebhookNotificationUrl -or $EventCompare) {
113113
if ($Existing.WebhookUrl) {
@@ -119,7 +119,7 @@ function New-CIPPGraphSubscription {
119119
}
120120

121121
$Uri = 'https://api.partnercenter.microsoft.com/webhooks/v1/registration'
122-
$GraphRequest = New-GraphPOSTRequest -uri $Uri -type $Method -tenantid $env:TenantId -scope 'https://api.partnercenter.microsoft.com/.default' -body ($Body | ConvertTo-Json) -NoAuthCheck $true
122+
$GraphRequest = New-GraphPOSTRequest -uri $Uri -type $Method -tenantid $env:TenantID -scope 'https://api.partnercenter.microsoft.com/.default' -body ($Body | ConvertTo-Json) -NoAuthCheck $true
123123

124124
$WebhookRow = @{
125125
PartitionKey = [string]$CIPPID

UpdatePermissions/run.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
param($Timer)
33

44
try {
5-
$Tenants = Get-Tenants -IncludeAll | Where-Object { $_.customerId -ne $env:TenantId -and $_.Excluded -eq $false }
5+
$Tenants = Get-Tenants -IncludeAll | Where-Object { $_.customerId -ne $env:TenantID -and $_.Excluded -eq $false }
66
$CPVTable = Get-CIPPTable -TableName cpvtenants
77
$CPVRows = Get-CIPPAzDataTableEntity @CPVTable
88
$ModuleRoot = (Get-Module CIPPCore).ModuleBase

0 commit comments

Comments
 (0)