Skip to content

Commit

Permalink
Merge branch 'main' into 17-add-database-repair
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaizoku authored Jan 23, 2023
2 parents 7560ecd + a88b6dd commit 4466ea1
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 30 deletions.
64 changes: 36 additions & 28 deletions Deploy-Alteryx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
- activate: activate the Alteryx application license
- backup: backup the Alteryx application database
- configure: configure the Alteryx application
- deactivate: deactivate the Alteryx application license
- install: install the Alteryx application
- repair: repair the Alteryx application database
- patch: patch upgrade the Alteryx application
- restart: restart the Alteryx application
- restore: restore a backup of the Alteryx application database
- show: display the script configuration
Expand Down Expand Up @@ -55,7 +57,7 @@
Param (
[Parameter (
Position = 1,
Mandatory = $false,
Mandatory = $true,
HelpMessage = "Action to perform"
)]
[ValidateSet (
Expand All @@ -64,6 +66,10 @@ Param (
"deactivate",
"install",
"repair",
"configure",
"deactivate",
"install",
"patch",
"restart",
"restore",
"show",
Expand All @@ -75,33 +81,33 @@ Param (
[System.String]
$Action,
[Parameter (
Position = 2,
Mandatory = $false,
HelpMessage = "Version parameter overwrite"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$Version,
[Parameter (
Position = 3,
Mandatory = $false,
HelpMessage = "Database backup path"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$BackupPath,
[Parameter (
Position = 4,
Mandatory = $false,
HelpMessage = "Product to install"
)]
[ValidateSet (
"Designer",
"Server"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$Product = "Server",
Position = 2,
Mandatory = $false,
HelpMessage = "Version parameter overwrite"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$Version,
[Parameter (
Position = 3,
Mandatory = $false,
HelpMessage = "Database backup path"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$BackupPath,
[Parameter (
Position = 4,
Mandatory = $false,
HelpMessage = "Product to install"
)]
[ValidateSet (
"Designer",
"Server"
)]
[ValidateNotNullOrEmpty ()]
[System.String]
$Product = "Server",
[Parameter (
Position = 5,
Mandatory = $false,
Expand Down Expand Up @@ -245,9 +251,11 @@ Process {
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 }
"restart" { Invoke-RestartAlteryx -Properties $Properties -Unattended:$Unattended }
"restore" { Invoke-RestoreAlteryx -Properties $Properties -Unattended:$Unattended }
"show" { Show-Configuration -Properties $Properties -InstallationProperties $InstallationProperties }
Expand Down
4 changes: 2 additions & 2 deletions powershell/Invoke-DeactivateAlteryx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Invoke-DeactivateAlteryx {
File name: Invoke-DeactivateAlteryx.ps1
Author: Florian Carrier
Creation date: 2021-11-20
Last modified: 2022-04-19
Last modified: 2023-01-17
.LINK
https://www.powershellgallery.com/packages/PSAYX
Expand Down Expand Up @@ -66,7 +66,7 @@ function Invoke-DeactivateAlteryx {
# Remove all license keys
$Deactivation = Remove-AlteryxLicense -Path $LicenseUtility
# Check deactivation status
if (Select-String -InputObject $Dectivation -Pattern "License(s) successfully removed." -SimpleMatch -Quiet) {
if (Select-String -InputObject $Deactivation -Pattern "License(s) successfully removed." -SimpleMatch -Quiet) {
Write-Log -Type "CHECK" -Message "All licenses were successfully deactivated"
} else {
# Output error
Expand Down
84 changes: 84 additions & 0 deletions powershell/Invoke-PatchAlteryx.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
function Invoke-PatchAlteryx {
<#
.SYNOPSIS
Install Alteryx patch
.DESCRIPTION
Perform a patch upgrade to Alteryx
.NOTES
File name: Invoke-PatchAlteryx.ps1
Author: Florian Carrier
Creation date: 2022-06-29
Last modified: 2022-06-29
#>
[CmdletBinding (
SupportsShouldProcess = $true
)]
Param (
[Parameter (
Position = 1,
Mandatory = $true,
HelpMessage = "Properties"
)]
[ValidateNotNullOrEmpty ()]
[System.Collections.Specialized.OrderedDictionary]
$Properties,
[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.ScriptName
# Variables
$ISOTimeStamp = Get-Date -Format "yyyyMMdd_HHmmss"
$Tags = [Ordered]@{"Version" = $Properties.Version}
# Filenames
if ($InstallationProperties.Product -eq "Designer") {
$PatchInstaller = "AlteryxPatchInstall_<Version>.exe"
} else {
$PatchInstaller = "AlteryxServerPatchInstall_<Version>.exe"
}
# Unattended execution arguments
if ($Unattended) {
$Arguments = "/s"
} else {
$Arguments = ""
}
}
Process {
Write-Log -Type "INFO" -Message "Installation of Alteryx $($InstallationProperties.Product) patch $($Properties.Version)"
if ($InstallationProperties.Product -eq "Designer" -Or $InstallationProperties.Server -eq $true) {
# Update file version number
$PatchFileName = Set-Tags -String $PatchInstaller -Tags (Resolve-Tags -Tags $Tags -Prefix "<" -Suffix ">")
$PatchPath = Join-Path -Path $Properties.SrcDirectory -ChildPath $PatchFileName
if ($PSCmdlet.ShouldProcess($PatchPath, "Install")) {
if (Test-Path -Path $PatchPath) {
if ($Properties.InstallAwareLog -eq $true) {
$InstallAwareLog = Join-Path -Path $Properties.LogDirectory -ChildPath "${ISOTimeStamp}_${PatchFileName}.log"
$PatchInstall = Install-AlteryxServer -Path $PatchPath -InstallDirectory $Properties.InstallationPath -Log $InstallAwareLog -Language $Properties.Language -AllUsers -Unattended:$Unattended
} else {
$PatchInstall = Install-AlteryxServer -Path $PatchPath -InstallDirectory $Properties.InstallationPath -Language $Properties.Language -AllUsers -Unattended:$Unattended
}
Write-Log -Type "DEBUG" -Message $PatchInstall
if ($PatchInstall.ExitCode -eq 0) {
Write-Log -Type "CHECK" -Message "Alteryx $($InstallationProperties.Product) patched successfully"
} else {
Write-Log -Type "ERROR" -Message "An error occured during the patch installation" -ExitCode $PatchInstall.ExitCode
}
} else {
Write-Log -Type "ERROR" -Message "Path not found $PatchPath"
Write-Log -Type "ERROR" -Message "Alteryx $($InstallationProperties.Product) patch file could not be located"
Write-Log -Type "WARN" -Message "Alteryx patch installation failed" -ExitCode 1
}
}
} else {
Write-Log -Type "ERROR" -Message "Designer or Server products must be enabled for a patch upgrade" -ExitCode 0
}
}
}

0 comments on commit 4466ea1

Please sign in to comment.