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

Invoke-DbaDbShrink doesn't accept pipeline input #9495

Open
Cryovenom opened this issue Oct 10, 2024 · 2 comments
Open

Invoke-DbaDbShrink doesn't accept pipeline input #9495

Cryovenom opened this issue Oct 10, 2024 · 2 comments
Labels
feature triage required New issue that has not been reviewed by maintainers

Comments

@Cryovenom
Copy link

Cryovenom commented Oct 10, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Following my Steps to Reproduce results in the following error:

Invoke-DbaDbShrink : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:2 char:23
+ $SimpleDatabases | Invoke-DbaDbShrink -FileType Log -WhatIf
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: ([TEAMMATE]:PSObject) [Invoke-DbaDbShrink], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Invoke-DbaDbShrink

Steps to Reproduce

If I have one or more database objects in a variable, I can't pass it to Invoke-DbaDbShrink on the pipeline.

So for example let's say I grab some databases like this:

$SimpleDatabases = Get-DbaDatabase -SqlInstance "SERVER01\InstanceA" -ExcludeSystem -RecoveryModel Simple

I can do this:

$SimpleDatabases | ForEach-Object { Invoke-DbaDbShrink -SqlInstance $_.SqlInstance -Database $_.Name }

But not this:

$SimpleDatabases | Invoke-DbaDbShrink -FileType Log

Attempting that results in the error I posted in the "What error did you receeive?" box above.

Please confirm that you are running the most recent version of dbatools

2.1.18

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


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

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU26) (KB5035123) - 15.0.4365.2 (X64) Mar 29 2024 23:02:47 Copyright (C) 2019 Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.4749.0

@Cryovenom Cryovenom added bugs life triage required New issue that has not been reviewed by maintainers labels Oct 10, 2024
@niphlod niphlod added feature and removed bugs life labels Oct 10, 2024
@niphlod
Copy link
Contributor

niphlod commented Oct 10, 2024

that's not a bug, it's a feature request. This function requires to pass database NAMES along, not Database SMO objects.

@Cryovenom
Copy link
Author

Cryovenom commented Oct 10, 2024

Sorry, I assumed it was already supposed to accept pipeline input and that it wasn't working properly (and thus, a bug) since pretty much all the other DbaTools cmdlets I use that target a database accept a Database object on the pipeline. It didn't occur to me that it would be a Feature Request.

In my script I just had this a line above:

$NotSimpleDatabases | Set-DbaDbRecoveryModel -RecoveryModel Simple -Confirm:$false

So it seemed logical that I could do this:

$SimpleDatabases | Invoke-DbaDbShrink -FileType Log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants