Skip to content

[Bug] Microsoft.SqlServer.Management.Smo.Server object may return null computername  #6632

@yoke88

Description

@yoke88

Environmental information

LCID             Name             DisplayName
----             ----             -----------
2052             zh-CN            中文(简体,中国)

SQL Server:

Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0 (X64)   Mar 18 2018 09:11:49   Copyright (c) Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor) 
简体中文

Host used

  • powershell.exe
  • ISE
  • VS Code
  • Other (please specify)

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

  • Still buggy in powershell.exe

Errors Received

警告: [10:23:35][Get-DecryptedObject] Can't access registry keys on mydb. Do you have administrative access to the
Windows registry on [mydb] Otherwise, we're out of ideas.

Steps to Reproduce

$dbatools=Import-Module dbatools -PassThru
& $dbatools{ Get-DecryptedObject -SqlInstance mydb -Type LinkedServer -Verbose}

Expected Behavior

i can get decrypted linkedserver list with password,but it always report an error like the above,so i add some debug in allcommands.ps1, and i found Microsoft.SqlServer.Management.Smo.Server object may return null computername. so the internal function like resolve-netbiosname、resolve-sqlipaddress should handle such situation.

Actual Behavior

详细信息: [10:26:17][Get-DecryptedObject] Querying service master key
详细信息: [mydb]
详细信息: myDB
详细信息: Microsoft.SqlServer.Management.Smo.Server
详细信息:
ComputerName Name Product              Version   HostPlatform IsAzure IsClustered ConnectedAs
------------ ---- -------              -------   ------------ ------- ----------- -----------
             mydb Microsoft SQL Server 13.0.4422 Windows              False


Write-Verbose : 无法将参数绑定到参数“Message”,因为该参数是空值。
所在位置 C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dbatools\allcommands.ps1:80651 字符: 19
+     write-verbose $server.ComputerName
+                   ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Write-Verbose],ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.WriteVerbos
   eCommand

Write-Verbose : 无法将参数绑定到参数“Message”,因为该参数是空值。
所在位置 C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dbatools\allcommands.ps1:76456 字符: 19
+     write-verbose $sourceNetBios
+                   ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Write-Verbose],ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.WriteVerbos
   eCommand

详细信息: [10:26:17][Get-DecryptedObject] Get entropy from the registry - hopefully finds the right SQL server instance
Get-DecryptedObject : 无法对参数“ComputerName”执行参数验证。参数为 Null 或空。请提供一个不为 Null 或空的参数,然后重
试该命令。
所在位置 行:1 字符: 14
+ & $dbatools{ Get-DecryptedObject -SqlInstance mydb -Type LinkedServer -Verbose}
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-DecryptedObject

警告: [10:26:17][Get-DecryptedObject] Can't access registry keys on mydb. Do you have administrative access to the
Windows registry on [mydb] Otherwise, we're out of ideas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugs lifeconfirmedLabel to be used by maintainers that confirm a bug does exist for the given issuesolution provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions