Skip to content

Commit

Permalink
Merge pull request #35 from SQLozano/main
Browse files Browse the repository at this point in the history
Added fix for "Encrypt"
  • Loading branch information
SQLozano authored Dec 14, 2023
2 parents 93ba8ff + 6a4a7f1 commit 30ee48b
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
8 changes: 6 additions & 2 deletions Installers/PivotedWaitStats_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Verify SQL version
if($Login){
Expand All @@ -29,10 +33,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/PlanMiner_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \PlanMiner
$SQLScripts = (Get-ChildItem -Path '..\PlanMiner' -Filter "*.sql") | Sort
Expand All @@ -17,10 +21,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
7 changes: 5 additions & 2 deletions Installers/QDSCacheCleanup_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Param(
[string]$Password
)
Import-Module SqlServer
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \QDSCacheCleanup
$SQLScripts = (Get-ChildItem -Path '..\QDSCacheCleanup' -Filter "*.sql") | Sort
Expand All @@ -17,10 +20,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/QueryReport_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Verify SQL version
if($Login){
Expand All @@ -29,10 +33,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/QueryVariation_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \QueryVariation
$SQLScripts = (Get-ChildItem -Path '..\QueryVariation' -Filter "*.sql") | Sort
Expand All @@ -17,10 +21,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/QueryWaits_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Verify SQL version
if($Login){
Expand All @@ -29,10 +33,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/ServerTopObjects_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \ServerTopObjects
$SQLScripts = (Get-ChildItem -Path '..\ServerTopObjects' -Filter "*.sql") | Sort
Expand All @@ -17,10 +21,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/ServerTopQueries_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \ServerTopQueries
$SQLScripts = (Get-ChildItem -Path '..\ServerTopQueries' -Filter "*.sql") | Sort
Expand All @@ -17,10 +21,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/StatisticsUsed_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Deploy all SQL script found in \StatisticsUsed
$SQLScripts = (Get-ChildItem -Path '..\StatisticsUsed' -Filter "*.sql") | Sort
Expand All @@ -17,10 +21,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}
8 changes: 6 additions & 2 deletions Installers/WaitsVariation_Installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Param(
[string]$Password
)
Import-Module SqlServer
# For versions >= 22 of the SqlServer PS module, the default encryption changed so it must be manually set Encrypt
if( (Get-Module -Name "sqlserver").Version.Major -ge 22){
$EncryptionParameter = @{Encrypt = "Optional"}
}

# Verify SQL version
if($Login){
Expand All @@ -29,10 +33,10 @@ foreach($Script in $SQLScripts){
# Deploy updated script
if($Login){
# Login / Password authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Username $Login -Password $Password -Query $ScriptContents @EncryptionParameter
}
else {
# Active Directory authentication
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents
Invoke-SqlCmd -ServerInstance $TargetInstance -Database $TargetDatabase -Query $ScriptContents @EncryptionParameter
}
}

0 comments on commit 30ee48b

Please sign in to comment.