The dbatools module's Find-DbaInstance
can accept a computer name and return a list of instances on that machine. Is there an equivalent in the SqlServer module that does this? I tried Get-SqlInstance
, but it seems to need actual instance names, as opposed to being able to use it for instance discovery. I'd prefer to use dbatools, but the SqlServer module is what I have consistent access to in the current environment.
CodePudding user response:
There are many good results that dont even depend on the sqlserver module in this article
eg.
$SQLInstances = Invoke-Command -ComputerName "localhost" {
(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
}
foreach ($sql in $SQLInstances) {
[PSCustomObject]@{
ServerName = $sql.PSComputerName
InstanceName = $sql
}
}