File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed
Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -379,13 +379,21 @@ function Get-DbaRegServer {
379379 Select-DefaultView - InputObject $server - Property $defaults
380380 }
381381
382- if ($IncludeSelf -and $servers ) {
382+ if ($IncludeSelf -and $SqlInstance -and $serverstore ) {
383383 Write-Message - Level Verbose - Message " Adding CMS instance"
384- $self = $servers [0 ].PsObject.Copy() | Select-Object - Property $defaults
385- $self | Add-Member - MemberType NoteProperty - Name Name - Value " CMS Instance" - Force
386- $self.ServerName = $instance
387- $self.Group = $null
388- $self.Description = $null
384+ $self = [PSCustomObject ]@ {
385+ Name = " CMS Instance"
386+ ServerName = $serverstore.SqlInstance
387+ Group = $null
388+ Description = $null
389+ Source = " Central Management Servers"
390+ ComputerName = $serverstore.ComputerName
391+ InstanceName = $serverstore.InstanceName
392+ SqlInstance = $serverstore.SqlInstance
393+ FQDN = $null
394+ IPAddress = $null
395+ }
396+ $self | Add-Member - MemberType ScriptMethod - Name ToString - Value { $this.ServerName } - Force
389397 Select-DefaultView - InputObject $self - Property $defaults
390398 }
391399 }
Original file line number Diff line number Diff line change @@ -135,6 +135,17 @@ Describe $CommandName -Tag IntegrationTests {
135135 $results | Where-Object ServerName -match " server1$" | Should -Not - BeNullOrEmpty
136136 }
137137
138+ It " Should include CMS instance itself with IncludeSelf and have piping-compatible properties" {
139+ $results = Get-DbaRegServer - SqlInstance $TestConfig.InstanceSingle - IncludeSelf
140+ $self = $results | Where-Object Name -eq " CMS Instance"
141+ $self | Should -Not - BeNullOrEmpty
142+ $self.ServerName | Should -Not - BeNullOrEmpty
143+ $self.ComputerName | Should -Not - BeNullOrEmpty
144+ $self.InstanceName | Should -Not - BeNullOrEmpty
145+ $self.SqlInstance | Should -Not - BeNullOrEmpty
146+ $self.ToString () | Should - Be $self.ServerName
147+ }
148+
138149 # Property Comparisons will come later when we have the commands
139150 }
140151}
You can’t perform that action at this time.
0 commit comments