PowerShell functions updated.

* More traps
* Assign undesirable output to $null
* Reorganize some execution plans

Change-Id: Ifb877ba3facc526baa2855432ad2d408cf23cb98
This commit is contained in:
Dmitry Teselkin 2013-08-09 00:43:07 +04:00
parent e73918da57
commit 3614cb1bdc
17 changed files with 95 additions and 40 deletions

View File

@ -14,11 +14,11 @@ Scripts:
- ../../WindowsPowerShell/Functions/New-SqlServerSystemAccount.ps1
Commands:
- Name: Install-SqlServerPowerShellModule
Arguments: {}
# - Name: Install-SqlServerPowerShellModule
# Arguments: {}
- Name: Disable-Firewall
Arguments: {}
# - Name: Disable-Firewall
# Arguments: {}
- Name: Enable-TrustedHosts
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

View File

@ -14,6 +14,9 @@ Scripts:
- ../../WindowsPowerShell/Functions/SQLServerForAOAG.ps1
Commands:
- Name: Disable-Firewall
Arguments: {}
- Name: Install-SQLServerForAOAG
Arguments:
# [String] (REQUIRED) Domain name
@ -22,3 +25,6 @@ Commands:
SQLServiceUserName: $domainAdminAccountName
# [String] (REQUIRED) Password for that user
SQLServiceUserPassword: $domainAdminAccountPassword
- Name: Install-SqlServerPowerShellModule
Arguments: {}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,8 @@
trap {
&$TrapHandler
}
function Export-Function {
param (
[String[]] $Name,

View File

@ -42,10 +42,14 @@
#>
trap {
&$TrapHandler
}
function Install-FailoverClusterPrerequisites {
Import-Module FailoverClusters
#Import-Module FailoverClusters
Add-WindowsFeature Failover-Clustering, RSAT-Clustering-PowerShell
}
@ -103,7 +107,7 @@ function New-FailoverClusterSharedFolder {
New-SmbShare -Path $SharePath `
-Name $ShareName `
-FullAccess "$ClusterAccount" `
-FullAccess "$ClusterAccount", 'Everyone' `
-Description "Shared folder for Failover Cluster."
} -ArgumentList $SharePath, $ShareName, "$DomainName\$ClusterName`$"

View File

@ -1,3 +1,10 @@
trap {
&$TrapHandler
}
Function ConvertTo-Boolean {
param (
$InputObject,
@ -11,12 +18,16 @@ Function ConvertTo-Boolean {
}
}
Function Show-Environment {
foreach ($item in (Get-ChildItem Env:)) {
Write-Log ("'{0}' --> '{1}'" -f $item.Name, $item.Value)
}
}
Function Install-SqlServer {
param (
[String] $SetupRoot = '',

View File

@ -1,3 +1,9 @@
trap {
&$TrapHandler
}
Function Join-Domain {
<#
.SYNOPSIS

View File

@ -1,4 +1,10 @@
trap {
&$TrapHandler
}
function New-SqlServerSystemAccount {
param (
# (REQUIRED) Domain Name

View File

@ -1,4 +1,8 @@
trap {
&$TrapHandler
}
function Install-SqlServerPowerShellModule {
param (
[String] $SetupRoot = ''
@ -146,7 +150,7 @@ function Initialize-AlwaysOnAvailabilityGroup {
$FunctionsFile = Export-Function 'Get-NextFreePort', 'Initialize-AlwaysOn'
Start-PowerShellProcess @"
$null = Start-PowerShellProcess @"
trap {
`$_
exit 1
@ -203,7 +207,7 @@ function New-SharedFolderForAOAG {
try {
Write-LogDebug "Trying to remove share '$ShareName'"
$null = Get-SmbShare -Name $ShareName -ErrorAction 'Stop'
Remove-SmbShare -Name $ShareName -Force
$null = Remove-SmbShare -Name $ShareName -Force
write-Log "Share '$ShareName' removed."
}
catch {
@ -213,7 +217,7 @@ function New-SharedFolderForAOAG {
try {
Write-LogDebug "Trying to remove folder '$SharePath"
$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."
}
catch {
@ -370,27 +374,29 @@ function Initialize-AOAGPrimaryReplica {
'ListenerDef' = $ListenerDefinition;
}
Remove-Item -Path "\\$PrimaryNode\SharedWorkDir\*" -Force
$null = Remove-Item -Path "\\$PrimaryNode\SharedWorkDir\*" -Force
$CliXmlFile = [IO.Path]::GetTempFileName()
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 `
-DomainName $DomainName `
-UserName $UserName `
-UserPassword $UserPassword `
-PrimaryNode $PrimaryNode
Write-LogDebug "Inner 'Initialize-AOAGPrimaryReplica' call completed."
}
else {
$Creds = New-Credential -UserName "$DomainName\$UserName" -Password "$UserPassword"
$FunctionsFile = Export-Function -All
Start-PowerShellProcess @"
$null = Start-PowerShellProcess @"
trap {
`$_
exit 1
@ -456,7 +462,7 @@ function Initialize-AOAGSecondaryReplica {
$FunctionsFile = Export-Function -All
Start-PowerShellProcess @"
$null = Start-PowerShellProcess @"
trap {
$_
exit 1

View File

@ -1,4 +1,10 @@
trap {
&$TrapHandler
}
function Select-CliXmlBlock {
param (
[String] $Path,

View File

@ -1,4 +1,10 @@
trap {
&$TrapHandler
}
function Update-ServiceConfig {
param (
[String] $Name,