SQL Server实例使用SQLServer PowerShell模块发现

发布于 2025-02-03 03:57:37 字数 202 浏览 4 评论 0原文

dbatools模块的find-dbainstance可以接受计算机名称并返回该计算机上的实例列表。 SQLServer模块中是否有等效的方法?我尝试了get-sqlinstance,但是它似乎需要实际的实例名称,而不是能够使用它例如发现它。我更喜欢使用dbatools,但是SQLServer模块是我在当前环境中始终访问的内容。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2025-02-10 03:57:37

本文

例如。

$SQLInstances = Invoke-Command -ComputerName "localhost" {
    (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
}

foreach ($sql in $SQLInstances) {
    [PSCustomObject]@{
        ServerName = $sql.PSComputerName
        InstanceName = $sql
    }
}

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
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文