forum.... still wkg on my POS skills. using dbatools.. I'm trying to run some informational queries, against multiple SQL instances. Is there a way to derive/use the server name from CMS to initialize the $server variable? How could I accomplish. I'm using:
Get-DbaRegisteredServer -SqlInstance CMSServer
There is a -ServerName parameter that contains the server name. How could I use it to do this, against each server (or any better way I'm open for)
Import-Module dbatools
$servers = "localhost\instance1" # this would be all the Live servers
get-dbadatabase -SqlInstance $servers -ExcludeDatabase master, model, msdb, tempdb | Select SqlInstance, Name, RecoveryModel, Compatibility, Owner, PageVerify, TargetRecoveryTime, IsReadCommittedSnapshotOn, SnapshotIsolationState, @{l="QueryStoreState";e={$_.QueryStoreOptions.ActualState}} | Export-Csv -Path c:\bin\databasestatus.csv
Thanks in advance!!