exports/Get-CVJob.ps1


# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Get list of jobs from the CommServe.
.Description
Get the list of all jobs.
Based on parameters this commandlet filters the output.
This method is implemented with Powershell paging support.
.Example
PS C:\> {{ Add code here }}
 
{{ Add output here }}
.Example
PS C:\> {{ Add code here }}
 
{{ Add output here }}
 
.Inputs
System.Int32
.Outputs
System.Management.Automation.PSObject
.Link
https://docs.microsoft.com/en-us/powershell/module/commvaultpowershell/get-cvjob
#>

function Get-CVJob {
[OutputType([System.Management.Automation.PSObject])]
[CmdletBinding(DefaultParameterSetName='Default', PositionalBinding=$false)]
param(
    [Parameter(ParameterSetName='Default')]
    [Commvault.Powershell.Category('Body')]
    [System.String]
    # Filter output based on ClientName.
    ${ClientName},

    [Parameter(ParameterSetName='Default')]
    [Commvault.Powershell.Category('Body')]
    [System.String]
    # Filter output based on SubclientName: requires ClientName parameter.
    ${SubclientName},

    [Parameter(ParameterSetName='Default')]
    [Alias('Filter')]
    [Commvault.Powershell.Category('Body')]
    [System.String]
    # Filter output based on JobFilter.
    # Example Snapbackup, DATA_VERIFICATION or SYNTHFULL etc.
    ${JobFilter},

    [Parameter(ParameterSetName='Default')]
    [Commvault.Powershell.Category('Body')]
    [System.String]
    # Filter output based on JobCategory.
    # Example Active, Finished, All.
    ${JobCategory},

    [Parameter(ParameterSetName='Default')]
    [Commvault.Powershell.Category('Body')]
    [System.Int32]
    # Filter output based on completed job lookup time expressed in hours.
    ${CompletedTime},

    [Parameter(ParameterSetName='Default')]
    [Commvault.Powershell.Category('Body')]
    [System.Int32]
    # The number of results to be listed in a page.
    # Used for changing the paging limits.
    # By default, the limit is 100 results per page.
    ${limit},

    [Parameter()]
    [Commvault.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    # Retrieves the details for a job.
    ${Details},

    [Parameter(ParameterSetName='ById', ValueFromPipeline, ValueFromPipelineByPropertyName)]
    [Commvault.Powershell.Category('Body')]
    [System.Int32]
    ${Id}
)

begin {
    try {
        $outBuffer = $null
        if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
            $PSBoundParameters['OutBuffer'] = 1
        }
        $parameterSet = $PSCmdlet.ParameterSetName
        $mapping = @{
            Default = 'CommvaultPowershell.custom\Get-CVJob';
            ById = 'CommvaultPowershell.custom\Get-CVJob';
        }
        $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
        $scriptCmd = {& $wrappedCmd @PSBoundParameters}
        $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
        $steppablePipeline.Begin($PSCmdlet)
    } catch {
        throw
    }
}

process {
    try {
        $steppablePipeline.Process($_)
    } catch {
        throw
    }
}

end {
    try {
        $steppablePipeline.End()
    } catch {
        throw
    }
}
}