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

Add switch to output in object (default to status quo) #237

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,6 +54,10 @@ function Get-CohesityProtectionJobStatus {
#>
[CmdletBinding()]
Param(
[Parameter(
Position = 1,
HelpMessage = "Return Output as Object")]
[Switch]$ReturnObject
)

Begin {
Expand Down Expand Up @@ -144,15 +148,19 @@ function Get-CohesityProtectionJobStatus {
)
$protectionJobStatusList += $status
}

$columnWidth = 20
$protectionJobStatusList | Sort-Object -Property startTime -Descending |
Format-Table @{ Label = 'ID'; Expression = { $_.jobId }; },
@{ Label = 'NAME'; Expression = { $_.jobName }; Width = $columnWidth; },
@{ Label = 'REMOTE COPY'; Expression = { $_.remoteCopy }; Width = $columnWidth },
@{ Label = 'STARTED AT'; Expression = { $_.GetStartTime() }; Width = $columnWidth },
@{ Label = 'ESTIMATED TIME'; Expression = { $_.GetEstimatedTime() }; Width = $columnWidth },
@{ Label = 'COMPLETED(%)'; Expression = { $_.percentCompleted }; Width = $columnWidth }
if ($ReturnObject -eq $True) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: $true

return $protectionJobStatusList
}
else {
$columnWidth = 20
$protectionJobStatusList | Sort-Object -Property startTime -Descending |
Format-Table @{ Label = 'ID'; Expression = { $_.jobId }; },
@{ Label = 'NAME'; Expression = { $_.jobName }; Width = $columnWidth; },
@{ Label = 'REMOTE COPY'; Expression = { $_.remoteCopy }; Width = $columnWidth },
@{ Label = 'STARTED AT'; Expression = { $_.GetStartTime() }; Width = $columnWidth },
@{ Label = 'ESTIMATED TIME'; Expression = { $_.GetEstimatedTime() }; Width = $columnWidth },
@{ Label = 'COMPLETED(%)'; Expression = { $_.percentCompleted }; Width = $columnWidth }
}
}

End {
Expand Down