From b88f0eef59b960aaf48ba04b0f43b2f26138afe2 Mon Sep 17 00:00:00 2001 From: vpedraja <131759263+vpedraja@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:23:53 +0200 Subject: [PATCH] Add new parameter to Publish-PerTenantExtensionApps (#3200) This implementation aims to include a new parameter on the Publish-PerTenantExtensionApps script in order to avoid the extension list output to show up in the psh console whenever a user runs the function. The default behavior would be to show that extension list before and after the extension installation but if the user wants to use this new parameter, they should be able to and the Write-Host with this data would not execute. --- Saas/Publish-PerTenantExtensionApps.ps1 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Saas/Publish-PerTenantExtensionApps.ps1 b/Saas/Publish-PerTenantExtensionApps.ps1 index 2a5fd8bdc..35b0779ef 100644 --- a/Saas/Publish-PerTenantExtensionApps.ps1 +++ b/Saas/Publish-PerTenantExtensionApps.ps1 @@ -20,7 +20,8 @@ .Parameter useNewLine Add this switch to add a newline to progress indicating periods during wait. Azure DevOps doesn't update logs until a newline is added. - + .Parameter hideInstalledExtensionsOutput + Add this parameter to hide the output that lists installed extensions on the specified environment before and after installation of new and updated PTE extensions. #> function Publish-PerTenantExtensionApps { [CmdletBinding(DefaultParameterSetName="AC")] @@ -41,7 +42,8 @@ function Publish-PerTenantExtensionApps { $appFiles, [ValidateSet('Add','Force')] [string] $schemaSyncMode = 'Add', - [switch] $useNewLine + [switch] $useNewLine, + [switch] $hideInstalledExtensionsOutput ) $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() @@ -91,9 +93,11 @@ try { $getExtensions = Invoke-WebRequest -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing $extensions = (ConvertFrom-Json $getExtensions.Content).value | Sort-Object -Property DisplayName - Write-Host "Extensions before:" - $extensions | ForEach-Object { Write-Host " - $($_.DisplayName), Version $($_.versionMajor).$($_.versionMinor).$($_.versionBuild).$($_.versionRevision), Installed=$($_.isInstalled)" } - Write-Host + if(!$hideInstalledExtensionsOutput) { + Write-Host "Extensions before:" + $extensions | ForEach-Object { Write-Host " - $($_.DisplayName), Version $($_.versionMajor).$($_.versionMinor).$($_.versionBuild).$($_.versionRevision), Installed=$($_.isInstalled)" } + Write-Host + } $body = @{"schedule" = "Current Version"} $appDep = $extensions | Where-Object { $_.DisplayName -eq 'Application' } @@ -230,9 +234,11 @@ try { $getExtensions = Invoke-WebRequest -Headers $authHeaders -Method Get -Uri "$automationApiUrl/companies($companyId)/extensions" -UseBasicParsing $extensions = (ConvertFrom-Json $getExtensions.Content).value | Sort-Object -Property DisplayName - Write-Host - Write-Host "Extensions after:" - $extensions | ForEach-Object { Write-Host " - $($_.DisplayName), Version $($_.versionMajor).$($_.versionMinor).$($_.versionBuild).$($_.versionRevision), Installed=$($_.isInstalled)" } + if (!$hideInstalledExtensionsOutput) { + Write-Host + Write-Host "Extensions after:" + $extensions | ForEach-Object { Write-Host " - $($_.DisplayName), Version $($_.versionMajor).$($_.versionMinor).$($_.versionBuild).$($_.versionRevision), Installed=$($_.isInstalled)" } + } } } catch [System.Net.WebException],[System.Net.Http.HttpRequestException] {