Skip to content

Commit

Permalink
so we dont have to repeat ourselves
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Sep 4, 2023
1 parent fcab7db commit 06c96ac
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions developing/Oslo Demo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,47 @@ $containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$show = 'All'

$PSDefaultParameterValues = @{
"*:SQlInstance" = $SQLInstances
"*:SqlCredential" = $cred
}
#endregion

#region What do we have?

Get-DbaDatabase -SqlInstance $Sqlinstances -SqlCredential $cred -ExcludeSystem | Select-Object Sqlinstance, DatabaseName, Status
Get-DbaDatabase | Select-Object Sqlinstance, Name, Status

Get-DbaAgentJob -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Name, Enabled
Get-DbaAgentJob | Select-Object Sqlinstance, Name, Enabled
#end region

Get-DbaLastBackup -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Database, LastFullBackup | Format-Table
Get-DbaLastBackup | Select-Object Sqlinstance, Database, LastFullBackup | Format-Table

# lets run a couple of tests

# this one shows that the old existing code will work
# the legacy switch is set to true by default

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show
Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show

# So lets show the shiny new faster code - legacy switch set to false

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false


# The Authentication check failed but we would like to pass - lets set config
Set-DbcConfig -Name policy.connection.authscheme -Value SQL

# run again

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false

# Hmmm, we know that we will never be able to remote onto these containers so let talk about skipping. No Claudio not that sort of skipping!!
Set-DbcConfig -Name skip.connection.remoting -Value $true

# run again

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false

# So much quicker !!! OK for one check it will be slower. For two it will probably be about the same but for 3 or more it will be quicker. Much quicket. Exrapolate that to 100 checks and a 1000 instances you can see the difference.

Expand All @@ -57,7 +62,7 @@ Invoke-PerfAndValidateCheck -Checks $Checks

# ok lets run the checks and save the out put to a variable so that we can show you what happens. Notice we need the -PassThru switch

$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false -PassThru
$CheckResults = Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false -PassThru

# this is our base results object
$CheckResults
Expand All @@ -68,6 +73,7 @@ $SomethingUseful = $CheckResults | Convert-DbcResult

$SomethingUseful
$SomethingUseful | Format-Table
#TODO: fix this Checking Instance Connection on on dbachecks3

$SomethingUseful | Select-Object -First 1

Expand All @@ -87,23 +93,25 @@ code ./oslo.json

# or put them into a database table

$CheckResults | Convert-DbcResult -Label 'CoffeeFilter' | Write-DbcTable -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Verbose
$CheckResults | Convert-DbcResult -Label 'claudiodidthis' | Write-DbcTable -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb

Invoke-DbaQuery -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Query 'SELECT * FROM CheckResults'
Invoke-DbaQuery -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Query 'SELECT COUNT(*) FROM CheckResults'

# AUDIENCE AND OTHER PRESENTERS - WE NEED REMINDERS HERE !!!
# YOU CANT DO THIS FROM HERE - Open Windows terminal on the host and run

Start-DbcPowerBi -FromDatabase

# AUDIENCE AND OTHER PRESENTERS - WE NEED REMINDERS HERE !!!
# then use localhost,7401 tempdb and u:sqladmin p:dbatools.IO

# question turn off a container adn talk about hte fails?
# question turn off a container and talk about the fails?


## made some funky results for the Power Bi

$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check Instance, Database -Show $show -legacy $false -PassThru
$CheckResults = Invoke-DbcCheck -Check Instance, Database -Show $show -legacy $false -PassThru

$CheckResults | Convert-DbcResult -Label 'DatabaseInstance' | Write-DbcTable -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Verbose

$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check compatibilitylevel -Show $show -legacy $false -PassThru
$CheckResults = Invoke-DbcCheck -Check compatibilitylevel -Show $show -legacy $false -PassThru

0 comments on commit 06c96ac

Please sign in to comment.