From 91834e18c4eae958f76357ef621bf50059fe18af Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:06:00 +0000 Subject: [PATCH 01/10] test durable on azure env --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 4a42db904b1a..3a146b7746d7 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants +$Tenants = Get-Tenants | Select -First 5 $Tenants \ No newline at end of file From 06559025c27d55c92846dfc17e6447ecaf565112 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:18:42 +0000 Subject: [PATCH 02/10] testing top 30 tenants --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 3a146b7746d7..68223d575e76 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 5 +$Tenants = Get-Tenants | Select -First 30 $Tenants \ No newline at end of file From 0c571c8500adda6ccded37ccbf6a98c362894ab4 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:20:57 +0000 Subject: [PATCH 03/10] 40 top tenants --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 68223d575e76..692daea64647 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 30 +$Tenants = Get-Tenants | Select -First 40 $Tenants \ No newline at end of file From 0e9fcdab94d9f65fcd016f14af88e247859e6bb6 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:25:35 +0000 Subject: [PATCH 04/10] top 50 --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 692daea64647..ffea317362b5 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 40 +$Tenants = Get-Tenants | Select -First 50 $Tenants \ No newline at end of file From ad254ac4fe04c59bcde64fdebfae58b10702b938 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:29:02 +0000 Subject: [PATCH 05/10] 30 again --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index ffea317362b5..68223d575e76 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 50 +$Tenants = Get-Tenants | Select -First 30 $Tenants \ No newline at end of file From ccced99241cdfe23fae22ad9af3ac66a7362dae7 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:38:06 +0000 Subject: [PATCH 06/10] 40 --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 68223d575e76..692daea64647 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 30 +$Tenants = Get-Tenants | Select -First 40 $Tenants \ No newline at end of file From 10323f37b6ecde60e675d19219fa4e302138730a Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:42:23 +0000 Subject: [PATCH 07/10] 35 --- Durable_AlertsQueue/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 692daea64647..a9455335b2a2 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,5 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 40 +$Tenants = Get-Tenants | Select -First 35 $Tenants \ No newline at end of file From 96a51282b057159da7a1235715df6b7f27c8a23b Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:53:24 +0000 Subject: [PATCH 08/10] 35 with write host --- Durable_AlertsQueue/run.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index a9455335b2a2..9e7d28aee87e 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -2,4 +2,6 @@ param($name) $Tenants = Get-Tenants | Select -First 35 -$Tenants \ No newline at end of file +$Tenants + +Write-Host $Tenants From 65d9d84a685726d2697cee71b72448a2774e4f88 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Thu, 25 Nov 2021 21:57:18 +0000 Subject: [PATCH 09/10] Amend to get-tenants with no select --- Durable_AlertsQueue/run.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Durable_AlertsQueue/run.ps1 b/Durable_AlertsQueue/run.ps1 index 9e7d28aee87e..737b2d68d825 100644 --- a/Durable_AlertsQueue/run.ps1 +++ b/Durable_AlertsQueue/run.ps1 @@ -1,7 +1,5 @@ param($name) -$Tenants = Get-Tenants | Select -First 35 +$Tenants = Get-Tenants $Tenants - -Write-Host $Tenants From 528b848002c2b47a7b326585555fa6dfc0ecbfe5 Mon Sep 17 00:00:00 2001 From: Adam Willford Date: Fri, 3 Dec 2021 10:53:35 +0000 Subject: [PATCH 10/10] ListCalPerms Not finished, but committing what I have currently which shows data --- ListCalendarPermissions/function.json | 19 ++++++++++++++ ListCalendarPermissions/run.ps1 | 38 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 ListCalendarPermissions/function.json create mode 100644 ListCalendarPermissions/run.ps1 diff --git a/ListCalendarPermissions/function.json b/ListCalendarPermissions/function.json new file mode 100644 index 000000000000..bec6849b58ab --- /dev/null +++ b/ListCalendarPermissions/function.json @@ -0,0 +1,19 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "Request", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "Response" + } + ] +} \ No newline at end of file diff --git a/ListCalendarPermissions/run.ps1 b/ListCalendarPermissions/run.ps1 new file mode 100644 index 000000000000..6b29aa5eabc7 --- /dev/null +++ b/ListCalendarPermissions/run.ps1 @@ -0,0 +1,38 @@ +using namespace System.Net + +# Input bindings are passed in via param block. +param($Request, $TriggerMetadata) + +$APIName = $TriggerMetadata.FunctionName +Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug" +$UserID = $request.Query.UserID +$Tenantfilter = $request.Query.tenantfilter +Write-Information "My username is $UserID" +Write-Information "My tenantfilter is $Tenantfilter" +if ($UserID -eq $null) { exit } +#$userid = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($username)" -tenantid $Tenantfilter).id +$UserDetails = New-GraphGetRequest -uri "https://outlook.office365.com/adminapi/beta/$($tenantfilter)/Mailbox('$UserID')" -Tenantid $tenantfilter -scope ExchangeOnline -noPagination $true +$Results = [System.Collections.ArrayList]@() +$upn = "notrequired@notrequired.com" +$tokenvalue = ConvertTo-SecureString (Get-GraphToken -AppID 'a0c73c16-a7e3-4564-9a95-2bdf47383716' -RefreshToken $ENV:ExchangeRefreshToken -Scope 'https://outlook.office365.com/.default' -Tenantid $tenantFilter).Authorization -AsPlainText -Force +$credential = New-Object System.Management.Automation.PSCredential($upn, $tokenValue) +$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell-liveid?DelegatedOrg=$($tenantFilter)&BasicAuthToOAuthConversion=true" -Credential $credential -Authentication Basic -AllowRedirection -ea Stop +$upn = 'notRequired@required.com' + + +try { + Import-PSSession $session -ea Silentlycontinue -AllowClobber -CommandName "Get-MailboxFolderPermission" + # $CalPerms = (Get-MailboxFolderPermission -Identity $($userid.PrimarySmtpAddress)) + $CalPerms = (Get-MailboxFolderPermission -Identity $($UserDetails.PrimarySmtpAddress)) + + Get-PSSession | Remove-PSSession + Log-request -API 'List Calendar Permissions' -tenant $tenantfilter -message "Calendar permissions listed for $($tenantfilter)" -sev Info +} catch { + Log-request -API 'List Calendar Permissions' -tenant $tenantfilter -message "Failed to list calendar permissions. Error: $($_.exception.message)" -sev Error +} + +# Associate values to output bindings by calling 'Push-OutputBinding'. +Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ + StatusCode = [HttpStatusCode]::OK + Body = $CalPerms +})