diff --git a/Deploy-Alteryx.ps1 b/Deploy-Alteryx.ps1 index fc0ee65..09ca7b5 100644 --- a/Deploy-Alteryx.ps1 +++ b/Deploy-Alteryx.ps1 @@ -11,12 +11,13 @@ .PARAMETER Action The action parameter corresponds to the operation to perform. - Fourteen options are available: + Fifteen options are available: - activate: activate the Alteryx application license - backup: backup the Alteryx application database - configure: configure the Alteryx application - deactivate: deactivate the Alteryx application license + - download: download latest Alteryx application release - install: install the Alteryx application - repair: repair the Alteryx application database - patch: patch upgrade the Alteryx application @@ -36,7 +37,7 @@ File name: Deploy-Alteryx.ps1 Author: Florian Carrier Creation date: 2021-06-13 - Last modified: 2024-02-12 + Last modified: 2024-09-11 Dependencies: - PowerShell Tool Kit (PSTK) - Alteryx PowerShell Module (PSAYX) @@ -65,6 +66,7 @@ Param ( "activate", "backup", "deactivate", + "download", "install", "repair", "configure", @@ -153,8 +155,8 @@ Begin { # ---------------------------------------------------------------------------- # Dependencies $Modules = [Ordered]@{ - "PSTK" = "1.2.4" - "PSAYX" = "1.0.1" + "PSTK" = "1.2.6" + "PSAYX" = "1.0.4" } # Load modules foreach ($Module in $Modules.GetEnumerator()) { @@ -197,7 +199,8 @@ Begin { # ------------------------------------------------------------------------------ # Ensure shell is running as 64 bit process if ([Environment]::Is64BitProcess -eq $false) { - Write-Log -Type "ERROR" -Message "PowerShell is running as a 32-bit process" -ExitCode 1 + Write-Log -Type "ERROR" -Message "PowerShell is running as a 32-bit process" + Write-Log -Type "INFO" -Message "Please run PowerShell as a 64-bit process" -ExitCode 1 } # ---------------------------------------------------------------------------- @@ -270,26 +273,48 @@ Begin { Process { # Check operation to perform switch ($Action) { - "activate" { Invoke-ActivateAlteryx -Properties $Properties -Unattended:$Unattended } - "backup" { Invoke-BackupAlteryx -Properties $Properties -Unattended:$Unattended } - "configure" { Set-Configuration -Properties $Properties -Unattended:$Unattended } - "deactivate" { Invoke-DeactivateAlteryx -Properties $Properties -Unattended:$Unattended } - "install" { Install-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } - "repair" { Repair-Alteryx -Properties $Properties -Unattended:$Unattended } - "patch" { Invoke-PatchAlteryx -Properties $Properties -Unattended:$Unattended } - "repair" { Repair-Alteryx -Properties $Properties -Unattended:$Unattended } - "restart" { Invoke-RestartAlteryx -Properties $Properties -Unattended:$Unattended } - "restore" { Invoke-RestoreAlteryx -Properties $Properties -Unattended:$Unattended } - "show" { Show-Configuration -Properties $Properties -InstallationProperties $InstallationProperties } - "start" { Invoke-StartAlteryx -Properties $Properties -Unattended:$Unattended } - "stop" { Invoke-StopAlteryx -Properties $Properties -Unattended:$Unattended } - "uninstall" { Uninstall-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } - "upgrade" { Update-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } - default { Write-Log -Type "ERROR" -Message """$Action"" operation is not supported" -ExitCode 1 } + "activate" { $Process = Invoke-ActivateAlteryx -Properties $Properties -Unattended:$Unattended } + "backup" { $Process = Invoke-BackupAlteryx -Properties $Properties -Unattended:$Unattended } + "configure" { $Process = Set-Configuration -Properties $Properties -Unattended:$Unattended } + "deactivate" { $Process = Invoke-DeactivateAlteryx -Properties $Properties -Unattended:$Unattended } + "download" { $Process = Invoke-DownloadAlteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } + "install" { $Process = Install-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } + "repair" { $Process = Repair-Alteryx -Properties $Properties -Unattended:$Unattended } + "patch" { $Process = Invoke-PatchAlteryx -Properties $Properties -Unattended:$Unattended } + "repair" { $Process = Repair-Alteryx -Properties $Properties -Unattended:$Unattended } + "restart" { $Process = Invoke-RestartAlteryx -Properties $Properties -Unattended:$Unattended } + "restore" { $Process = Invoke-RestoreAlteryx -Properties $Properties -Unattended:$Unattended } + "show" { $Process = Show-Configuration -Properties $Properties -InstallationProperties $InstallationProperties } + "start" { $Process = Invoke-StartAlteryx -Properties $Properties -Unattended:$Unattended } + "stop" { $Process = Invoke-StopAlteryx -Properties $Properties -Unattended:$Unattended } + "uninstall" { $Process = Uninstall-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } + "upgrade" { $Process = Update-Alteryx -Properties $Properties -InstallationProperties $InstallationProperties -Unattended:$Unattended } + default { Write-Log -Type "ERROR" -Message """$Action"" operation is not supported" -ExitCode 1 } } } End { - # Stop script and transcript - Stop-Script -ExitCode 0 + # Check outcome and gracefully end script + Write-Log -Type "DEBUG" -Message ($Process | Format-Table) + if ($Process.Success -And ($Process.Status -eq "Completed")) { + Write-Log -Type "CHECK" -Message "Alteryx $Action process completed successfully" -ExitCode $Process.ExitCode + } else { + if ($Process.ErrorCount -gt 0) { + if ($Process.ErrorCount -gt 1) { + $Errors = "with $($Process.ErrorCount) errors" + } else { + $Errors = "with $($Process.ErrorCount) error" + } + } else { + $Errors = "" + } + switch ($Process.Status) { + "Cancelled" { $Outcome = "was cancelled" } + "Completed" { $Outcome = "completed" } + "Failed" { $Outcome = "failed" } + "Stopped" { $Outcome = "was stopped" } + default { $Outcome = "failed" } + } + Write-Log -Type "ERROR" -Message "Alteryx $Action process $Outcome $Errors" -ExitCode $Process.ExitCode + } } \ No newline at end of file diff --git a/conf/default.ini b/conf/default.ini index 860a998..3369862 100644 --- a/conf/default.ini +++ b/conf/default.ini @@ -35,7 +35,9 @@ InstallationOptions = install.ini # Installation language Language = English # Version -Version = 2022.1.1.25127 +Version = 2024.1.1.136 +# Service name +ServiceName = AlteryxService # InstallAware log InstallAwareLog = false # Activate Alteryx during installation @@ -50,6 +52,10 @@ LicensingURL = whitelist.alteryx.com LicenseFile = # License email LicenseEmail = +# License Account ID +LicenseAccountID = +# License API refresh token file +LicenseAPIFile = [SSL] # SSL/TLS diff --git a/powershell/Invoke-DownloadAlteryx.ps1 b/powershell/Invoke-DownloadAlteryx.ps1 new file mode 100644 index 0000000..6c6c6c0 --- /dev/null +++ b/powershell/Invoke-DownloadAlteryx.ps1 @@ -0,0 +1,119 @@ +function Invoke-DownloadAlteryx { + <# + .SYNOPSIS + Download Alteryx release + + .DESCRIPTION + Download the latest Alteryx release for a specified product + + .NOTES + File name: Invoke-DownloadAlteryx.ps1 + Author: Florian Carrier + Creation date: 2024-09-04 + Last modified: 2024-09-06 + #> + [CmdletBinding ()] + Param ( + [Parameter ( + Position = 1, + Mandatory = $true, + HelpMessage = "Script properties" + )] + [ValidateNotNullOrEmpty ()] + [System.Collections.Specialized.OrderedDictionary] + $Properties, + [Parameter ( + Position = 2, + Mandatory = $true, + HelpMessage = "Installation properties" + )] + [ValidateNotNullOrEmpty ()] + [System.Collections.Specialized.OrderedDictionary] + $InstallationProperties, + [Parameter ( + HelpMessage = "Non-interactive mode" + )] + [Switch] + $Unattended + ) + Begin { + # Get global preference vrariables + Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState + # Log function call + Write-Log -Type "DEBUG" -Message $MyInvocation.MyCommand.Name + # Process status + $Process = New-ProcessObject -Name $MyInvocation.MyCommand.Name + # Product IDs + $Products = [Ordered]@{ + "Designer" = "Alteryx Designer" + "Server" = "Alteryx Server" + } + $ProductID = $Products.$($InstallationProperties.Product) + # License API refresh token + $RefreshToken = Get-Content -Path $Properties.LicenseAPIFile -Raw + # Placeholder + $Skip = $false + } + Process { + $Process = Update-ProcessObject -ProcessObject $Process -Status "Running" + # Get license API access token + $AccessToken = Update-AlteryxLicenseToken -Token $RefreshToken -Type "Access" + Write-Log -Type "DEBUG" -Message $AccessToken + # Check current and target versions + $CurrentVersion = Get-AlteryxVersion + $MajorVersion = [System.String]::Concat([System.Version]::Parse($CurrentVersion).Major , ".", [System.Version]::Parse($CurrentVersion).Minor) + $TargetVersion = [System.String]::Concat([System.Version]::Parse($Properties.Version).Major, ".", [System.Version]::Parse($Properties.Version).Minor) + # Check latest version + Write-Log -Type "INFO" -Message "Retrieve latest release for $ProductID version $TargetVersion" + $Release = Get-AlteryxLatestRelease -AccountID $Properties.LicenseAccountID -Token $AccessToken -ProductID $ProductID -Version $TargetVersion + # Compare versions + if (Compare-Version -Version $Release.Version -Operator "lt" -Reference $CurrentVersion) { + Write-Log -Type "WARN" -Message "The specified version ($($Release.Version)) is lower than the current one ($CurrentVersion)" + if (($Unattended -eq $false) -And (-Not (Confirm-Prompt -Prompt "Do you still want to download $ProductID version $($Release.Version)?"))) { + $Skip = $true + } + } elseif (Compare-Version -Version $Release.Version -Operator "eq" -Reference $CurrentVersion) { + Write-Log -Type "WARN" -Message "The version installed ($CurrentVersion) is the latest version available for $ProductID" + if (($Unattended -eq $false) -And (-Not (Confirm-Prompt -Prompt "Do you still want to download $ProductID version $($Release.Version)?"))) { + $Skip = $true + } + } else { + Write-Log -Type "INFO" -Message "$ProductID version $($Release.Version) is available" + if (-Not $Unattended) { + $Continue = Confirm-Prompt -Prompt "Do you want to download it?" + if (-Not $Continue) { + $Skip = $true + } + } + } + # Check if download should proceed + if ($Skip -eq $false) { + # Check if + if (Compare-Version -Version $TargetVersion -Operator "ne" -Reference $MajorVersion) { + # If major upgrade, download installer + Write-Log -Type "INFO" -Message "Downloading $($Release.Product) version $($Release.Version)" + } else { + # If minor or patch upgrade, download patch + Write-Log -Type "INFO" -Message "Downloading $($Release.Product) patch version $($Release.Version)" + $Release = Get-AlteryxLatestRelease -AccountID $Properties.LicenseAccountID -Token $AccessToken -ProductID $ProductID -Version $TargetVersion -Patch + } + $DownloadPath = Join-Path -Path $Properties.SrcDirectory -ChildPath $Release.FileName + Invoke-WebRequest -Uri $Release.URL -OutFile $DownloadPath + # Check downloaded file + Write-Log -Type "DEBUG" -Message $DownloadPath + if (Test-Path -Path $DownloadPath) { + Write-Log -Type "CHECK" -Message "Download completed successfully" + $Process = Update-ProcessObject -ProcessObject $Process -Status "Completed" -Success $true -ExitCode 0 -ErrorCount 0 + } else { + Write-Log -Type "ERROR" -Message "Download failed" + $Process = Update-ProcessObject -ProcessObject $Process -Status "Failed" -Success $false -ExitCode 1 -ErrorCount 1 + } + } else { + Write-Log -Type "WARN" -Message "Skipping download process" + $Process = Update-ProcessObject -ProcessObject $Process -Status "Cancelled" -Success $true -ExitCode 0 -ErrorCount 0 + } + } + End { + return $Process + } +} \ No newline at end of file