0

I am getting the following error when running this command:

Get-dbaDatabase -sqlinstance server01 -NoFullBackup

Error:

Compare-DbaCollationSensitiveObject : Cannot bind argument to parameter 'Value' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\dbatools\1.1.76\allcommands.ps1:22322 char:109
+ ... bject -Property Name -In -Value $lastCopyOnlyBackups.Database -Collat ...
+                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Compare-DbaCollationSensitiveObject], ParameterBindingValidationExcept
   ion
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Compare-DbaCollationSensitiveObject

This happens on multiple versions of dbatools, I don't think it is related to dbatools at all. When I run this on another account that has a profile created long ago I get no errors. New account profiles seem to have this error show up. I am thinking it may be related to a setting in PowerShell but I am not sure what it could be.

On an older account profile the command just returns nothing, basically a blank line. The newer accounts all return this error. I have run this command on machines ranging from Windows Server 2012 through Windows Server 2019.

I did try to use an account that worked on an older server on a new server and in that case I do get the error above. It seems to be related to when the profile was created, which makes me think there is some default setting or behavior that is being set at the group policy or machine policy level.

PowerShell version is 5.1.

I am hoping there are some PowerShell experts out there that can point me in the right direction.

Thanks!

Charlieface
  • 52,284
  • 6
  • 19
  • 43
packfan73
  • 1
  • 1
  • Looks like a bug to me. Looking at the [source code](https://www.powershellgallery.com/packages/dbatools/1.1.76/Content/functions%5CGet-DbaDatabase.ps1): `Get-DbaDatabase` with `-NoFullBackup` filters out databases that do not have full backups. It does this by calling `Get-DbaDbBackupHistory`, then passing that result's `.Database` to `Compare-DbaCollationSensitiveObject` to compare to the full list of database names. But `Compare-DbaCollationSensitiveObject` requires a non-null value, and in the event there are no databases with full backups then no check is made for that. – Charlieface Mar 09 '22 at 23:39
  • I suggest you file this with the writers of DbaTools – Charlieface Mar 09 '22 at 23:40
  • OK, the interesting thing is that when I run it under one account it works as expected, just returning the blank line. I was wondering if there was some kind of PowerShell setting handling how NULL's are being passed, similar to something like ANSI NULL's in SQL Server. I will look at opening a bug with the dbatools project also. Thanks – packfan73 Mar 10 '22 at 01:16
  • Might be a permissions issue, perhaps run it as `sa` – Charlieface Mar 10 '22 at 02:04
  • I will open something up with the project, it looks like the module started using the Compare-dbaCollationSensitiveObject sometime between 1.1.36 and 1.1.65. Prior to that it just used a simple Where-Object to filter it. Thanks! – packfan73 Mar 10 '22 at 14:59
  • I opened a bug with the project and they were able to reproduce the issue. I also found out that the working user was because I must have had a PS session open before I updated dbatools and that was still using the old functionality, when I closed out and logged back in it was broken there also. It appears the new compare function was added around November 2021. – packfan73 Mar 11 '22 at 16:16
  • Feel free to answer or close your own question – Charlieface Mar 11 '22 at 16:18

1 Answers1

0

This has been acknowledged as a bug in the function by the dbatools team. This is fairly new functionality that was implemented in late 2021. This should get fixed in a future update to dbatools.

packfan73
  • 1
  • 1