Skip to content

Commit

Permalink
Add new parameter to Publish-PerTenantExtensionApps (#3200)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vpedraja authored Oct 4, 2023
1 parent 59089f7 commit b88f0ee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Saas/Publish-PerTenantExtensionApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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 @()
Expand Down Expand Up @@ -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' }
Expand Down Expand Up @@ -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] {
Expand Down

0 comments on commit b88f0ee

Please sign in to comment.