Skip to content

Commit

Permalink
removed some write hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Mar 28, 2023
1 parent 84de215 commit 0102e1a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Activity_AddOrUpdateTableRows/run.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
param($TableParams)
$TableName = ($TableParams.Context['TableName'])
$Table = Get-CippTable -tablename $TableName
Write-Host "The table is $TableName"

foreach ($param in $TableParams.Entity) {
try {
#Sending each item indivually, if it fails, log an error.
Add-AzDataTableEntity @Table -Entity $param -Force
}
catch {
Write-Host $($_.Exception.Message)
Write-LogMessage -API 'Activity_AddOrUpdateTableRows' -message "Unable to write to '$($TableParams.TableName)' Using RowKey $($param.RowKey) table: $($_.Exception.Message)" -sev error
}
}
1 change: 0 additions & 1 deletion AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ $Results = foreach ($Tenant in $tenants) {
property = $CompleteObject
UpdateExisting = $true
}#>
Write-Host ($TableRow | ConvertTo-Json)

#Add-AzTableRow @TableRow | Out-Null
Add-AzDataTableEntity @Table -Entity $CompleteObject -Force
Expand Down
7 changes: 4 additions & 3 deletions GraphHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $refreshToken, $Retur
$AccessToken = (Invoke-RestMethod -Method post -Uri "https://login.microsoftonline.com/$($tenantid)/oauth2/v2.0/token" -Body $Authbody -ErrorAction Stop)
if ($ReturnRefresh) { $header = $AccessToken } else { $header = @{ Authorization = "Bearer $($AccessToken.access_token)" } }
return $header
Write-Host $header['Authorization']
}
catch {
# Track consecutive Graph API failures
Expand Down Expand Up @@ -381,10 +380,12 @@ function Get-Tenants {
}
$IncludedTenantsCache = Get-AzDataTableEntity @TenantsTable -Filter $Filter

$LastRefresh = ($IncludedTenantsCache | Sort-Object LastRefresh | Select-Object -First 1).LastRefresh.DateTime

$LastRefresh = ($IncludedTenantsCache | Where-Object -Property $_.customerId | Sort-Object LastRefresh | Select-Object -First 1).LastRefresh.DateTime
Write-Host ($IncludedTenantsCache | Where-Object -Property $_.customerId | Sort-Object LastRefresh | Select-Object -First 1 | ConvertTo-Json)
if ($LastRefresh -lt (Get-Date).Addhours(-24).ToUniversalTime()) {
try {
Write-Host 'Renewing. Cache not hit.'

$TenantList = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/managedTenants/tenants?`$top=999" -tenantid $env:TenantID ) | Select-Object id, @{l = 'customerId'; e = { $_.tenantId } }, @{l = 'DefaultdomainName'; e = { [string]($_.contract.defaultDomainName) } } , @{l = 'MigratedToNewTenantAPI'; e = { $true } }, DisplayName, domains, tenantStatusInformation | Where-Object -Property defaultDomainName -NotIn $SkipListCache.defaultDomainName
}
catch {
Expand Down

0 comments on commit 0102e1a

Please sign in to comment.