Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Restore-DbaDatabase reports more than 1 database passed in when only 1 was passed #5425

Closed
1 task
dbaduck opened this issue Apr 29, 2019 · 1 comment
Closed
1 task

Comments

@dbaduck
Copy link
Contributor

dbaduck commented Apr 29, 2019

Before submitting a bug report:

Collect output of following command and paste below:

& {"### PowerShell version:`n$($PSVersionTable | Out-String)"; "`n### dbatools Module version:`n$(gmo dbatools -List | select name, path, version | fl -force | Out-String)"}

PowerShell version:

Name Value


PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

dbatools Module version:

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.812\dbatools.psd1
Version : 0.9.812

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.804\dbatools.psd1
Version : 0.9.804

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.801\dbatools.psd1
Version : 0.9.801

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.797\dbatools.psd1
Version : 0.9.797

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.793\dbatools.psd1
Version : 0.9.793

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.784\dbatools.psd1
Version : 0.9.784

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.773\dbatools.psd1
Version : 0.9.773

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.771\dbatools.psd1
Version : 0.9.771

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.701\dbatools.psd1
Version : 0.9.701

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.518\dbatools.psd1
Version : 0.9.518

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.418\dbatools.psd1
Version : 0.9.418

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.333\dbatools.psd1
Version : 0.9.333

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.324\dbatools.psd1
Version : 0.9.324

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.321\dbatools.psd1
Version : 0.9.321

Name : dbatools
Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.307\dbatools.psd1
Version : 0.9.307

  • [X ] Running latest release of dbatools
  • [X ] Verified errors are not related to permissions
  • Is this bug with Copy-DbaDatabase? You can replicate it using Backup-DbaDatabase ... | Restore-DbaDatabase ...

NOTE: Copy-DbaDatabase will not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.

Environmental data

<# REPLACE WITH output OF environment one-liner #>

SQL Server:

/* REPLACE WITH output of @@VERSION */

Errors Received

<# OUTPUT of $error[0] | select * #>

Steps to Reproduce

/*
    Any T-SQL commands involved or used to produce test objects/data.
*/
<#
    Provide exact (or sanitized) code to reproduce the error
#>

$istoryObject = Get-DbaBackupHistory -SqlInstance localhost -Database DEMODB

$istoryObject | Restore-DbaDatabase -SqlInstance localhost -DatabaseName DEMODB_copy -TrustDbBackupHistory -ReplaceDbNameInFile -OutputScriptOnly

WARNING: [22:51:36][Restore-DbaDatabase] Multiple Databases' backups passed in, but only 1 name to restore them under. Stopping as cannot work out how to proceed

Expected Behavior

That it continues on because there is only really one database in the Backup History.

Actual Behavior

Select-Object -Unique is case sensitive, so I ended up having the Restore-DbaDatabase terminate because there appeared to be 2 databases passed in even though there was only 1.

If you change the Select-Object -Unique to Sort-Object -Unique it will not give that error if there happens to be DEMODB and demodb in the list of database History records. Select-Object and Get-Unique are case sensitive and Sort-Object is not.

@potatoqualitee
Copy link
Member

thank you for the report and solution, Ben!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants