133 lines
4.7 KiB
PowerShell
133 lines
4.7 KiB
PowerShell
|
function Optimize-CIPackageInstallList {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Used to take an RM provided list of packages and re-categorize it to help CIx installs.
|
||
|
Specifically this will remove certain packages from being installed to help speed up install time, and reduce conflicts
|
||
|
This function will place contents on your clipboard, then prompt you to continue so you can get the next set.
|
||
|
|
||
|
.PARAMETER Path
|
||
|
[string] Specify a file where you copy-paste the contents from Jira, because automation should be consistent.
|
||
|
|
||
|
.PARAMETER Contents
|
||
|
[string[]] Specify a string array containing the elements you want recategorized. Should be a copy-paste of the contents from Jira, because the automation there should be consistent.
|
||
|
#>
|
||
|
[CmdletBinding(DefaultParameterSetName = 'Path')]
|
||
|
param(
|
||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Path')]
|
||
|
[string]$Path,
|
||
|
|
||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Contents')]
|
||
|
[string[]]$Contents
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName)
|
||
|
|
||
|
if ($PSCmdlet.ParameterSetName -eq 'Path') {
|
||
|
$Contents = (Get-Content -Path $Path)
|
||
|
}
|
||
|
|
||
|
$colesRejectedPackageList = @(
|
||
|
'billpayproviders'
|
||
|
'remotedepositproviders'
|
||
|
'rdc'
|
||
|
'symconnect'
|
||
|
'cardmanagementproviders'
|
||
|
)
|
||
|
|
||
|
$appInstalls = @()
|
||
|
$appUninstalls = @()
|
||
|
$webInstalls = @()
|
||
|
$webUninstalls = @()
|
||
|
|
||
|
$inAppInstalls = $false
|
||
|
$inAppUninstalls = $false
|
||
|
$inWebInstalls = $false
|
||
|
$inWebUninstalls = $false
|
||
|
foreach($line in $Contents) {
|
||
|
$line = $line.Trim()
|
||
|
if ([string]::IsNullOrWhiteSpace($line)) { continue }
|
||
|
|
||
|
if ($line.StartsWith('Uninstall the following elements on the App Tier')) {
|
||
|
$inAppInstalls = $false
|
||
|
$inAppUninstalls = $true
|
||
|
$inWebInstalls = $false
|
||
|
$inWebUninstalls = $false
|
||
|
continue
|
||
|
} elseif ($line.StartsWith('Install the following elements on the App Tier')) {
|
||
|
$inAppInstalls = $true
|
||
|
$inAppUninstalls = $false
|
||
|
$inWebInstalls = $false
|
||
|
$inWebUninstalls = $false
|
||
|
continue
|
||
|
} elseif ($line.StartsWith('Uninstall the following elements on the Web Tier')) {
|
||
|
$inAppInstalls = $false
|
||
|
$inAppUninstalls = $false
|
||
|
$inWebInstalls = $false
|
||
|
$inWebUninstalls = $true
|
||
|
continue
|
||
|
} elseif ($line.StartsWith('Install the following elements on the Web Tier')) {
|
||
|
$inAppInstalls = $false
|
||
|
$inAppUninstalls = $false
|
||
|
$inWebInstalls = $true
|
||
|
$inWebUninstalls = $false
|
||
|
continue
|
||
|
} elseif ($line.StartsWith('Changes Include:')) {
|
||
|
# done!
|
||
|
break
|
||
|
} elseif ($inAppInstalls) {
|
||
|
$badPattern = $false
|
||
|
$lowerLine = $line.ToLower()
|
||
|
foreach($entry in $colesRejectedPackageList) {
|
||
|
if (!$badPattern -and ($lowerLine.IndexOf($entry) -gt -1)) {
|
||
|
$badPattern = $true
|
||
|
}
|
||
|
}
|
||
|
if ($badPattern) {
|
||
|
$appUninstalls += ($line -split ' ')[0]
|
||
|
} else {
|
||
|
$appInstalls += $line
|
||
|
}
|
||
|
} elseif ($inAppUninstalls) {
|
||
|
$appUninstalls += ($line -split ' ')[0]
|
||
|
} elseif ($inWebInstalls) {
|
||
|
$badPattern = $false
|
||
|
$lowerLine = $line.ToLower()
|
||
|
foreach($entry in $colesRejectedPackageList) {
|
||
|
if (!$badPattern -and ($lowerLine.IndexOf($entry) -gt -1)) {
|
||
|
$badPattern = $true
|
||
|
}
|
||
|
}
|
||
|
if ($badPattern) {
|
||
|
$webUninstalls += ($line -split ' ')[0]
|
||
|
} else {
|
||
|
$webInstalls += $line
|
||
|
}
|
||
|
} elseif ($inWebUninstalls) {
|
||
|
$webUninstalls += ($line -split ' ')[0]
|
||
|
} else {
|
||
|
#
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$appInstalls = $appInstalls | Sort-Object -Unique
|
||
|
$appUninstalls = $appUninstalls | Sort-Object -Unique
|
||
|
$webInstalls = $webInstalls | Sort-Object -Unique
|
||
|
$webUninstalls = $webUninstalls | Sort-Object -Unique
|
||
|
|
||
|
Read-Host "Press any key to copy to clipboard the appInstall block"
|
||
|
($appInstalls -join "`n") | Set-Clipboard
|
||
|
|
||
|
Read-Host "Press any key to copy to clipboard the appUninstall block"
|
||
|
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||
|
($appUninstalls -join "`n") | Set-Clipboard
|
||
|
|
||
|
Read-Host "Press any key to copy to clipboard the webInstall block"
|
||
|
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||
|
($webInstalls -join "`n") | Set-Clipboard
|
||
|
|
||
|
Read-Host "Press any key to copy to clipboard the webUninstall block"
|
||
|
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||
|
($webUninstalls -join "`n") | Set-Clipboard
|
||
|
|
||
|
Write-Host "Run finished"
|
||
|
}
|