dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

find-dbadbgrowthEvent with convertto-dbatimeline

Open AndiM1976 opened this issue 3 years ago • 5 comments

Summarize Functionality

Hi, I tried to use find-dbadbgrowthEvent with convertto-dbatimeline (find-dbadbgrowthEvent -sqlinstance | convertto-dbatimeline| out-file <file.html> ). PS throw an error with unsupport input data. Please expand dbatools cmdlet with this feature.

Cheers Andi

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

No response

AndiM1976 avatar Jan 05 '22 15:01 AndiM1976

Thanks @AndiM1976 ! cool idea. @marcingminski would you be able to take a look?

potatoqualitee avatar Jan 17 '22 19:01 potatoqualitee

Can you share your code?

marcingminski avatar Jan 17 '22 22:01 marcingminski

Hi there, I had a look. Looks like the ConvertTo-DbaTimeLine has been made to only accept input from certain commands as below. I will see if I can make it to accept arbitrary input

        if ($InputObject[0].TypeName -eq 'AgentJobHistory') {
            $CallerName = "Get-DbaAgentJobHistory"
            $data = $InputObject | Select-Object @{ Name = "SqlInstance"; Expression = { $_.SqlInstance } }, @{ Name = "InstanceName"; Expression = { $_.InstanceName } }, @{ Name = "vLabel"; Expression = { "[" + $($_.SqlInstance -replace "\\", "\\\") + "] " + $_.Job -replace "\'", '' } }, @{ Name = "hLabel"; Expression = { $_.Status } }, @{ Name = "Style"; Expression = { $(Convert-DbaTimelineStatusColor($_.Status)) } }, @{ Name = "StartDate"; Expression = { $(ConvertTo-JsDate($_.StartDate)) } }, @{ Name = "EndDate"; Expression = { $(ConvertTo-JsDate($_.EndDate)) } }
        } elseif ($InputObject[0] -is [Sqlcollaborative.Dbatools.Database.BackupHistory]) {
            $CallerName = " Get-DbaDbBackupHistory"
            $data = $InputObject | Select-Object @{ Name = "SqlInstance"; Expression = { $_.SqlInstance } }, @{ Name = "InstanceName"; Expression = { $_.InstanceName } }, @{ Name = "vLabel"; Expression = { "[" + $($_.SqlInstance -replace "\\", "\\\") + "] " + $_.Database } }, @{ Name = "hLabel"; Expression = { $_.Type } }, @{ Name = "StartDate"; Expression = { $(ConvertTo-JsDate($_.Start)) } }, @{ Name = "EndDate"; Expression = { $(ConvertTo-JsDate($_.End)) } }
        } else {
            # sorry to be so formal, can't help it ;)
            Stop-Function -Message "Unsupported input data. To request support for additional commands, please file an issue at dbatools.io/issues and we'll take a look"
            return
        }
        $body += "$($data | ForEach-Object{ "['$($_.vLabel)','$($_.hLabel)','$($_.Style)',$($_.StartDate), $($_.EndDate)]," })"

marcingminski avatar Jan 19 '22 12:01 marcingminski

Do you have time to work on this one?

andreasjordan avatar Jun 11 '23 12:06 andreasjordan

Nope, completely forgot. Thanks for the reminder.

marcingminski avatar Jun 11 '23 14:06 marcingminski