PowerShell functions updated.
* More traps * Assign undesirable output to $null * Reorganize some execution plans Change-Id: Ifb877ba3facc526baa2855432ad2d408cf23cb98
This commit is contained in:
parent
e73918da57
commit
3614cb1bdc
|
@ -14,11 +14,11 @@ Scripts:
|
||||||
- ../../WindowsPowerShell/Functions/New-SqlServerSystemAccount.ps1
|
- ../../WindowsPowerShell/Functions/New-SqlServerSystemAccount.ps1
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
- Name: Install-SqlServerPowerShellModule
|
# - Name: Install-SqlServerPowerShellModule
|
||||||
Arguments: {}
|
# Arguments: {}
|
||||||
|
|
||||||
- Name: Disable-Firewall
|
# - Name: Disable-Firewall
|
||||||
Arguments: {}
|
# Arguments: {}
|
||||||
|
|
||||||
- Name: Enable-TrustedHosts
|
- Name: Enable-TrustedHosts
|
||||||
Arguments: {}
|
Arguments: {}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,9 @@ Scripts:
|
||||||
- ../../WindowsPowerShell/Functions/SQLServerForAOAG.ps1
|
- ../../WindowsPowerShell/Functions/SQLServerForAOAG.ps1
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
- Name: Disable-Firewall
|
||||||
|
Arguments: {}
|
||||||
|
|
||||||
- Name: Install-SQLServerForAOAG
|
- Name: Install-SQLServerForAOAG
|
||||||
Arguments:
|
Arguments:
|
||||||
# [String] (REQUIRED) Domain name
|
# [String] (REQUIRED) Domain name
|
||||||
|
@ -22,3 +25,6 @@ Commands:
|
||||||
SQLServiceUserName: $domainAdminAccountName
|
SQLServiceUserName: $domainAdminAccountName
|
||||||
# [String] (REQUIRED) Password for that user
|
# [String] (REQUIRED) Password for that user
|
||||||
SQLServiceUserPassword: $domainAdminAccountPassword
|
SQLServiceUserPassword: $domainAdminAccountPassword
|
||||||
|
|
||||||
|
- Name: Install-SqlServerPowerShellModule
|
||||||
|
Arguments: {}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
function Export-Function {
|
function Export-Function {
|
||||||
param (
|
param (
|
||||||
[String[]] $Name,
|
[String[]] $Name,
|
||||||
|
|
|
@ -42,10 +42,14 @@
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Install-FailoverClusterPrerequisites {
|
function Install-FailoverClusterPrerequisites {
|
||||||
Import-Module FailoverClusters
|
#Import-Module FailoverClusters
|
||||||
|
|
||||||
Add-WindowsFeature Failover-Clustering, RSAT-Clustering-PowerShell
|
Add-WindowsFeature Failover-Clustering, RSAT-Clustering-PowerShell
|
||||||
}
|
}
|
||||||
|
@ -103,7 +107,7 @@ function New-FailoverClusterSharedFolder {
|
||||||
|
|
||||||
New-SmbShare -Path $SharePath `
|
New-SmbShare -Path $SharePath `
|
||||||
-Name $ShareName `
|
-Name $ShareName `
|
||||||
-FullAccess "$ClusterAccount" `
|
-FullAccess "$ClusterAccount", 'Everyone' `
|
||||||
-Description "Shared folder for Failover Cluster."
|
-Description "Shared folder for Failover Cluster."
|
||||||
|
|
||||||
} -ArgumentList $SharePath, $ShareName, "$DomainName\$ClusterName`$"
|
} -ArgumentList $SharePath, $ShareName, "$DomainName\$ClusterName`$"
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function ConvertTo-Boolean {
|
Function ConvertTo-Boolean {
|
||||||
param (
|
param (
|
||||||
$InputObject,
|
$InputObject,
|
||||||
|
@ -11,12 +18,16 @@ Function ConvertTo-Boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function Show-Environment {
|
Function Show-Environment {
|
||||||
foreach ($item in (Get-ChildItem Env:)) {
|
foreach ($item in (Get-ChildItem Env:)) {
|
||||||
Write-Log ("'{0}' --> '{1}'" -f $item.Name, $item.Value)
|
Write-Log ("'{0}' --> '{1}'" -f $item.Name, $item.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function Install-SqlServer {
|
Function Install-SqlServer {
|
||||||
param (
|
param (
|
||||||
[String] $SetupRoot = '',
|
[String] $SetupRoot = '',
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Function Join-Domain {
|
Function Join-Domain {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function New-SqlServerSystemAccount {
|
function New-SqlServerSystemAccount {
|
||||||
param (
|
param (
|
||||||
# (REQUIRED) Domain Name
|
# (REQUIRED) Domain Name
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
function Install-SqlServerPowerShellModule {
|
function Install-SqlServerPowerShellModule {
|
||||||
param (
|
param (
|
||||||
[String] $SetupRoot = ''
|
[String] $SetupRoot = ''
|
||||||
|
@ -146,7 +150,7 @@ function Initialize-AlwaysOnAvailabilityGroup {
|
||||||
|
|
||||||
$FunctionsFile = Export-Function 'Get-NextFreePort', 'Initialize-AlwaysOn'
|
$FunctionsFile = Export-Function 'Get-NextFreePort', 'Initialize-AlwaysOn'
|
||||||
|
|
||||||
Start-PowerShellProcess @"
|
$null = Start-PowerShellProcess @"
|
||||||
trap {
|
trap {
|
||||||
`$_
|
`$_
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -203,7 +207,7 @@ function New-SharedFolderForAOAG {
|
||||||
try {
|
try {
|
||||||
Write-LogDebug "Trying to remove share '$ShareName'"
|
Write-LogDebug "Trying to remove share '$ShareName'"
|
||||||
$null = Get-SmbShare -Name $ShareName -ErrorAction 'Stop'
|
$null = Get-SmbShare -Name $ShareName -ErrorAction 'Stop'
|
||||||
Remove-SmbShare -Name $ShareName -Force
|
$null = Remove-SmbShare -Name $ShareName -Force
|
||||||
write-Log "Share '$ShareName' removed."
|
write-Log "Share '$ShareName' removed."
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
@ -213,7 +217,7 @@ function New-SharedFolderForAOAG {
|
||||||
try {
|
try {
|
||||||
Write-LogDebug "Trying to remove folder '$SharePath"
|
Write-LogDebug "Trying to remove folder '$SharePath"
|
||||||
$null = Get-Item -Path $SharePath -ErrorAction 'Stop'
|
$null = Get-Item -Path $SharePath -ErrorAction 'Stop'
|
||||||
Remove-Item -Path $SharePath -Recurse -Force
|
$null = Remove-Item -Path $SharePath -Recurse -Force
|
||||||
Write-Log "Folder '$SharePath' removed."
|
Write-Log "Folder '$SharePath' removed."
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
@ -370,27 +374,29 @@ function Initialize-AOAGPrimaryReplica {
|
||||||
'ListenerDef' = $ListenerDefinition;
|
'ListenerDef' = $ListenerDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
Remove-Item -Path "\\$PrimaryNode\SharedWorkDir\*" -Force
|
$null = Remove-Item -Path "\\$PrimaryNode\SharedWorkDir\*" -Force
|
||||||
|
|
||||||
$CliXmlFile = [IO.Path]::GetTempFileName()
|
$CliXmlFile = [IO.Path]::GetTempFileName()
|
||||||
|
|
||||||
Write-LogDebug "CliXml file: '$CliXmlFile'"
|
Write-LogDebug "CliXml file: '$CliXmlFile'"
|
||||||
|
|
||||||
Export-CliXml -Path $CliXmlFile -InputObject $Parameters -Depth 10
|
$null = Export-CliXml -Path $CliXmlFile -InputObject $Parameters -Depth 10
|
||||||
|
|
||||||
Initialize-AOAGPrimaryReplica `
|
$null = Initialize-AOAGPrimaryReplica `
|
||||||
-CliXmlFile $CliXmlFile `
|
-CliXmlFile $CliXmlFile `
|
||||||
-DomainName $DomainName `
|
-DomainName $DomainName `
|
||||||
-UserName $UserName `
|
-UserName $UserName `
|
||||||
-UserPassword $UserPassword `
|
-UserPassword $UserPassword `
|
||||||
-PrimaryNode $PrimaryNode
|
-PrimaryNode $PrimaryNode
|
||||||
|
|
||||||
|
Write-LogDebug "Inner 'Initialize-AOAGPrimaryReplica' call completed."
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Creds = New-Credential -UserName "$DomainName\$UserName" -Password "$UserPassword"
|
$Creds = New-Credential -UserName "$DomainName\$UserName" -Password "$UserPassword"
|
||||||
|
|
||||||
$FunctionsFile = Export-Function -All
|
$FunctionsFile = Export-Function -All
|
||||||
|
|
||||||
Start-PowerShellProcess @"
|
$null = Start-PowerShellProcess @"
|
||||||
trap {
|
trap {
|
||||||
`$_
|
`$_
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -456,7 +462,7 @@ function Initialize-AOAGSecondaryReplica {
|
||||||
|
|
||||||
$FunctionsFile = Export-Function -All
|
$FunctionsFile = Export-Function -All
|
||||||
|
|
||||||
Start-PowerShellProcess @"
|
$null = Start-PowerShellProcess @"
|
||||||
trap {
|
trap {
|
||||||
$_
|
$_
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Select-CliXmlBlock {
|
function Select-CliXmlBlock {
|
||||||
param (
|
param (
|
||||||
[String] $Path,
|
[String] $Path,
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
|
|
||||||
|
trap {
|
||||||
|
&$TrapHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Update-ServiceConfig {
|
function Update-ServiceConfig {
|
||||||
param (
|
param (
|
||||||
[String] $Name,
|
[String] $Name,
|
||||||
|
|
Loading…
Reference in New Issue