Skip to content

Commit 06c96ac

Browse files
so we dont have to repeat ourselves
1 parent fcab7db commit 06c96ac

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

developing/Oslo Demo.ps1

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,47 @@ $containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks
77
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
88
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
99
$show = 'All'
10+
11+
$PSDefaultParameterValues = @{
12+
"*:SQlInstance" = $SQLInstances
13+
"*:SqlCredential" = $cred
14+
}
1015
#endregion
1116

1217
#region What do we have?
1318

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

16-
Get-DbaAgentJob -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Name, Enabled
21+
Get-DbaAgentJob | Select-Object Sqlinstance, Name, Enabled
1722
#end region
1823

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

2126
# lets run a couple of tests
2227

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

26-
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show
31+
Invoke-DbcCheck -Check InstanceConnection, DatabaseStatus -Show $show
2732

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

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

3237

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

3641
# run again
3742

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

4045
# 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!!
4146
Set-DbcConfig -Name skip.connection.remoting -Value $true
4247

4348
# run again
4449

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

4752
# 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.
4853

@@ -57,7 +62,7 @@ Invoke-PerfAndValidateCheck -Checks $Checks
5762

5863
# 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
5964

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

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

6974
$SomethingUseful
7075
$SomethingUseful | Format-Table
76+
#TODO: fix this Checking Instance Connection on on dbachecks3
7177

7278
$SomethingUseful | Select-Object -First 1
7379

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

8894
# or put them into a database table
8995

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

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

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

96103
Start-DbcPowerBi -FromDatabase
97104

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

100-
# question turn off a container adn talk about hte fails?
108+
# question turn off a container and talk about the fails?
101109

102110

103111
## made some funky results for the Power Bi
104112

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

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

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

0 commit comments

Comments
 (0)