-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34f2ca1
commit 756d2ff
Showing
3 changed files
with
852 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Get-AllInstanceInfo testing | ||
|
||
# so the initial load doesnt skew the figures | ||
ipmo dbatools | ||
function prompt { Write-Host "pwsh >" -NoNewline; ' '} | ||
|
||
# load the original function | ||
. .\originalGet-AllInstanceInfo.ps1 | ||
. .\NewGet-AllInstance.ps1 | ||
|
||
# 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' | ||
$smos = Connect-DbaInstance -SqlInstance $Sqlinstances -SqlCredential $cred | ||
|
||
foreach($smo in $smos){ | ||
Get-AllInstanceInfo -Instance $smo -Tags 'DefaultTrace','OleAutomationProceduresDisabled','CrossDBOwnershipChaining','ScanForStartupProceduresDisabled','RemoteAccessDisabled','SQLMailXPsDisabled' -There $true | ||
} | ||
} | ||
|
||
# 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' | ||
$smos = Connect-DbaInstance -SqlInstance $Sqlinstances -SqlCredential $cred | ||
|
||
foreach($smo in $smos){ | ||
NewGet-AllInstanceInfo -Instance $smo -Tags 'DefaultTrace','OleAutomationProceduresDisabled','CrossDBOwnershipChaining','ScanForStartupProceduresDisabled','RemoteAccessDisabled','SQLMailXPsDisabled' -There $true | ||
} | ||
} | ||
|
||
$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 | ||
|
||
Write-PSFMessage -Message $originalCodeMessage -Level Significant | ||
Write-PSFMessage -Message $NewCodeMessage -Level Significant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function NewGet-AllInstanceInfo { | ||
# Using the unique tags gather the information required | ||
Param($Instance, $Tags) | ||
|
||
#clear out the default initialised fields | ||
$smo.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Server], $false) | ||
$smo.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Database], $false) | ||
$smo.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Login], $false) | ||
$smo.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Agent.Job], $false) | ||
|
||
# COnfiguration cannot have default init fields :-) | ||
$configurations = $false | ||
|
||
# Using there so that if the instance is not contactable, no point carrying on with gathering more information | ||
switch ($tags) { | ||
|
||
'DefaultTrace' { | ||
$configurations = $true | ||
} | ||
'OleAutomationProceduresDisabled' { | ||
$configurations = $true | ||
} | ||
'CrossDBOwnershipChaining' { | ||
$configurations = $true | ||
} | ||
'ScanForStartupProceduresDisabled' { | ||
$configurations = $true | ||
} | ||
'RemoteAccessDisabled' { | ||
$configurations = $true | ||
} | ||
'SQLMailXPsDisabled' { | ||
$configurations = $true | ||
} | ||
|
||
Default { } | ||
} | ||
|
||
# set the default init fields for all the tags | ||
|
||
#build the object | ||
|
||
$testInstanceObject = [PSCustomObject]@{ | ||
ComputerName = $smo.ComputerName | ||
InstanceName = $smo.DbaInstanceName | ||
Configuration = if ($configurations) { $Smo.Configuration }else { $null } | ||
} | ||
return $testInstanceObject | ||
} |
Oops, something went wrong.