Skip to content

Commit

Permalink
the testing files
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Apr 25, 2022
1 parent ac52c1b commit cf15b15
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 56 deletions.
61 changes: 54 additions & 7 deletions Get-AllInstanceInfo testing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

# so the initial load doesnt skew the figures
ipmo dbatools
function prompt { Write-Host "pwsh >" -NoNewline; ' '}

ipmo ./dbachecks.psd1
function prompt { Write-Host "pwsh >" -NoNewline; ' ' }
cls
# load the original function
. .\originalGet-AllInstanceInfo.ps1
. .\NewGet-AllInstance.ps1
. .\internal\functions\NewGet-AllInstanceInfo.ps1

$SPConfigureChecks = 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation'

# Lets check just the spconfigure ones :D
$originalCode = {
Expand All @@ -16,8 +19,8 @@ $originalCode = {
$Sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
$smos = Connect-DbaInstance -SqlInstance $Sqlinstances -SqlCredential $cred

foreach($smo in $smos){
Get-AllInstanceInfo -Instance $smo -Tags 'DefaultTrace','OleAutomationProceduresDisabled','CrossDBOwnershipChaining','ScanForStartupProceduresDisabled','RemoteAccessDisabled','SQLMailXPsDisabled' -There $true
foreach ($smo in $smos) {
Get-AllInstanceInfo -Instance $smo -Tags $SPConfigureChecks -There $true
}
}

Expand All @@ -29,8 +32,8 @@ $NewCode = {
$Sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
$smos = Connect-DbaInstance -SqlInstance $Sqlinstances -SqlCredential $cred

foreach($smo in $smos){
NewGet-AllInstanceInfo -Instance $smo -Tags 'DefaultTrace','OleAutomationProceduresDisabled','CrossDBOwnershipChaining','ScanForStartupProceduresDisabled','RemoteAccessDisabled','SQLMailXPsDisabled' -There $true
foreach ($smo in $smos) {
NewGet-AllInstanceInfo -Instance $smo -Tags $SPConfigureChecks -There $true
}
}

Expand All @@ -39,6 +42,50 @@ $NewCodetrace = Trace-Script -ScriptBlock $NewCode

$originalCodeMessage = "With original Code it takes {0} MilliSeconds" -f $originalCodetrace.StopwatchDuration.TotalMilliseconds
$NewCodeMessage = "With New Code it takes {0} MilliSeconds" -f $NewCodetrace.StopwatchDuration.TotalMilliseconds
cls
Write-PSFMessage -Message $originalCodeMessage -Level Significant
Write-PSFMessage -Message $NewCodeMessage -Level Significant

# Check it works
function prompt { Write-Host "pwsh >" -NoNewline; ' ' }
cls
ipmo ./dbachecks.psd1

$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$Sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'

Invoke-DbcCheck -SqlInstance $Sqlinstances -Check DefaultTrace -SqlCredential $cred -legacy $false
Invoke-DbcCheck -SqlInstance $Sqlinstances -Check DefaultTrace -SqlCredential $cred -legacy $true

$SPConfigureChecks = 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation'
Invoke-DbcCheck -SqlInstance $Sqlinstances -Check $SPConfigureChecks -SqlCredential $cred -legacy $true
Invoke-DbcCheck -SqlInstance $Sqlinstances -Check $SPConfigureChecks -SqlCredential $cred -legacy $false


# Lets check just the spconfigure ones :D
$originalCode = {
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$Sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'

Invoke-DbcCheck -SqlInstance $Sqlinstances -Check 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' -SqlCredential $cred -legacy $true -Show None
}

# Lets check just the spconfigure ones :D
$NewCode = {
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$Sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'

Invoke-DbcCheck -SqlInstance $Sqlinstances -Check 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' -SqlCredential $cred -legacy $false -Show None
}

$originalCodetrace = Trace-Script -ScriptBlock $originalCode
$NewCodetrace = Trace-Script -ScriptBlock $NewCode

$originalCodeMessage = "With original Code it takes {0} MilliSeconds" -f $originalCodetrace.StopwatchDuration.TotalMilliseconds
$NewCodeMessage = "With New Code it takes {0} MilliSeconds" -f $NewCodetrace.StopwatchDuration.TotalMilliseconds
cls
Write-PSFMessage -Message $originalCodeMessage -Level Significant
Write-PSFMessage -Message $NewCodeMessage -Level Significant
49 changes: 0 additions & 49 deletions NewGet-AllInstance.ps1

This file was deleted.

0 comments on commit cf15b15

Please sign in to comment.