From ff8872612d01a7161b017c2ac5190c687c35c1c6 Mon Sep 17 00:00:00 2001 From: Lukas Gosling <71852244+l-gosling@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:55:30 +0200 Subject: [PATCH] added purview (ipp) connection --- .github/workflows/test-action.yml | 1 + README.md | 2 ++ action.yml | 6 ++++++ script/Run-MaesterAction.ps1 | 32 ++++++++++++++++++++++++------- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 4aba902..c3f46d7 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -59,6 +59,7 @@ jobs: include_public_tests: true include_private_tests: false include_exchange: false + include_purview: false include_teams: false step_summary: ${{ matrix.maester == 'preview'}} artifact_upload: true diff --git a/README.md b/README.md index 2385056..e4eea53 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Check out the [Maester documentation](https://maester.dev/) for more information | `include_public_tests` | Install public tests from module | ❌ | `true` | | `include_private_tests` | Include private tests from the current repository. | ❌ | `true` | | `include_exchange` | Include Exchange Online tests in the test run. | ❌ | `false` | +| `include_purview` | Include Purview tests in the test run. | ❌ | `false` | | `include_teams` | Include Teams tests in the test run. | ❌ | `true` | | `include_tags` | A list of tags to include in the test run (comma-separated). | ❌ | | | `exclude_tags` | A list of tags to exclude from the test run (comma-separated). | ❌ | | @@ -96,6 +97,7 @@ jobs: include_public_tests: true include_private_tests: false include_exchange: false + include_purview: false include_teams: false # Set a specific version of the powershell module here or 'latest' or 'preview' # check out https://www.powershellgallery.com/packages/Maester/ diff --git a/action.yml b/action.yml index a14d072..d09151c 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,11 @@ inputs: description: "Include Exchange Online tests in the test run." required: false default: false + include_purview: + type: boolean + description: "Include Purview tests in the test run." + required: false + default: false include_teams: type: boolean description: "Include Teams tests in the test run." @@ -153,6 +158,7 @@ runs: -MaesterVersion '${{ inputs.maester_version }}' ` -IncludePublicTests('${{ inputs.include_public_tests }}' -eq 'true') ` -IncludeExchange ('${{ inputs.include_exchange }}' -eq 'true') ` + -IncludePurview ('${{ inputs.include_purview }}' -eq 'true') ` -IncludeTeams ('${{ inputs.include_teams }}' -eq 'true') ` -IncludeTags '${{ inputs.include_tags }}' ` -ExcludeTags '${{ inputs.exclude_tags }}' ` diff --git a/script/Run-MaesterAction.ps1 b/script/Run-MaesterAction.ps1 index e0adb7e..ace6b7a 100644 --- a/script/Run-MaesterAction.ps1 +++ b/script/Run-MaesterAction.ps1 @@ -33,6 +33,9 @@ [Parameter(Mandatory = $false, HelpMessage = 'Include Exchange Online tests')] [bool]$IncludeExchange = $true, + [Parameter(Mandatory = $false, HelpMessage = 'Include Purview tests')] + [bool]$IncludePurview = $false, + [Parameter(Mandatory = $false, HelpMessage = 'Include Teams tests')] [bool]$IncludeTeams = $true, @@ -136,16 +139,31 @@ PROCESS { Connect-MgGraph -AccessToken $graphToken -NoWelcome Write-Host "✔️ Graph connected" - # Check if we need to connect to Exchange Online - if ($IncludeExchange) { + # Check if we need to connect to Exchange Online or Purview + if ($IncludeExchange -or $IncludePurview) { Install-Module ExchangeOnlineManagement -Force Import-Module ExchangeOnlineManagement $outlookToken = Get-MtAccessTokenUsingCli -ResourceUrl 'https://outlook.office365.com' - Connect-ExchangeOnline -AccessToken $outlookToken -AppId $ClientId -Organization $TenantId -ShowBanner:$false - Write-Host "✔️ Exchange Online connected." - } else { - Write-Host '📃 Exchange Online tests will be skipped.' + + # Check if we need to connect to Exchange Online + if ($IncludeExchange) { + Connect-ExchangeOnline -AccessToken $outlookToken -AppId $ClientId -Organization $TenantId -ShowBanner:$false + Write-Host "✔️ Exchange Online connected." + } else { + Write-Host '📃 Exchange Online tests will be skipped.' + } + + # Check if we need to connect to Purview + if ($IncludePurview) { + $domains = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/domains?`$select=id,isDefault" + $primaryDomain = $domains.value | Where-Object { $_.isDefault -eq $true } | Select-Object -ExpandProperty id + + Connect-IPPSSession -AccessToken $outlookToken -Organization $primaryDomain -ShowBanner:$false + Write-Host "✔️ Purview connected." + } else { + Write-Host '📃 Purview tests will be skipped.' + } } # Check if we need to connect to Teams @@ -157,7 +175,7 @@ PROCESS { $regularGraphToken = ConvertFrom-SecureString -SecureString $graphToken -AsPlainText $tokens = @($regularGraphToken, $teamsToken) - Connect-MicrosoftTeams -AccessTokens $tokens -Verbose + Connect-MicrosoftTeams -AccessTokens $tokens Write-Host "✔️ Microsoft Teams connected." } else { Write-Host '📃 Teams tests will be skipped.'