exports/New-SysManPrinter.ps1

<#
.Synopsis
Creates a new printer based on the provided information
.Description
Creates a new printer based on the provided information
.Link
https://docs.microsoft.com/en-us/powershell/module/sysman.webapi/new-sysmanprinter
#>

function New-SysManPrinter {
[OutputType('System.Int64', 'SysMan.Powershell.Models.IApiErrorMessage')]
[CmdletBinding(DefaultParameterSetName='Create', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[SysMan.Powershell.Description('Creates a new printer based on the provided information')]
param(
    [Parameter(ParameterSetName='Create', ValueFromPipeline, HelpMessage='A printer represent a Queue. A printer can be installed on clients.')]
    [SysMan.Powershell.Category('Body')]
    [SysMan.Powershell.Models.IPrinter]
    ${Printer},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='If the printer can be assigned as default printer during installation')]
    [SysMan.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    ${CanBeDefault},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='If the printer can be removed. Usually used by external systems (example: Login script) to handle cases where theprinter should be removed each login and installed again.')]
    [SysMan.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    ${CanBeRemoved},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='When the printer was created')]
    [SysMan.Powershell.Category('Body')]
    [System.DateTime]
    ${CreatedDate},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='The description of the printer')]
    [SysMan.Powershell.Category('Body')]
    [System.String]
    ${Description},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='The id of the printer')]
    [SysMan.Powershell.Category('Body')]
    [System.Int64]
    ${Id},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='The internal version used to flag if the printer should be upgraded or not. Is is external systems responsibility(Example: login script) to handledetection if a version has changed.')]
    [SysMan.Powershell.Category('Body')]
    [System.Int32]
    ${InternalDriverVersion},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='If the printer is active or nor. Inactive printer can be used to filter out printers that should not be handled byusers')]
    [SysMan.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    ${IsActive},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='The date the printer was last modified')]
    [SysMan.Powershell.Category('Body')]
    [System.DateTime]
    ${LastModifiedDate},

    [Parameter(ParameterSetName='CreateExpanded', HelpMessage='The location of the printer. Mostly used as meta data to help technicians which printer to pick when intalling themon clients')]
    [SysMan.Powershell.Category('Body')]
    [System.String]
    ${Location},

    [Parameter(ParameterSetName='CreateExpanded', Mandatory, HelpMessage='The name. Often used together with Server to create a printer path')]
    [SysMan.Powershell.Category('Body')]
    [System.String]
    ${Name},

    [Parameter(ParameterSetName='CreateExpanded', Mandatory, HelpMessage='The server. Often used together with Name to create a printer path')]
    [SysMan.Powershell.Category('Body')]
    [System.String]
    ${Server},

    [Parameter(DontShow, HelpMessage='Wait for .NET debugger to attach')]
    [SysMan.Powershell.Category('Runtime')]
    [System.Management.Automation.SwitchParameter]
    ${Break},

    [Parameter(DontShow, HelpMessage='SendAsync Pipeline Steps to be appended to the front of the pipeline')]
    [ValidateNotNull()]
    [SysMan.Powershell.Category('Runtime')]
    [SysMan.Powershell.Runtime.SendAsyncStep[]]
    ${HttpPipelineAppend},

    [Parameter(DontShow, HelpMessage='SendAsync Pipeline Steps to be prepended to the front of the pipeline')]
    [ValidateNotNull()]
    [SysMan.Powershell.Category('Runtime')]
    [SysMan.Powershell.Runtime.SendAsyncStep[]]
    ${HttpPipelinePrepend},

    [Parameter(DontShow, HelpMessage='The URI for the proxy server to use')]
    [SysMan.Powershell.Category('Runtime')]
    [System.Uri]
    ${Proxy},

    [Parameter(DontShow, HelpMessage='Credentials for a proxy server to use for the remote call')]
    [ValidateNotNull()]
    [SysMan.Powershell.Category('Runtime')]
    [System.Management.Automation.PSCredential]
    ${ProxyCredential},

    [Parameter(DontShow, HelpMessage='Use the default credentials for the proxy')]
    [SysMan.Powershell.Category('Runtime')]
    [System.Management.Automation.SwitchParameter]
    ${ProxyUseDefaultCredentials}
)

begin {
    try {
        $outBuffer = $null
        if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
            $PSBoundParameters['OutBuffer'] = 1
        }
        $parameterSet = $PsCmdlet.ParameterSetName
        $mapping = @{
            Create = 'SysMan.WebApi.private\New-SysManPrinter_Create';
            CreateExpanded = 'SysMan.WebApi.private\New-SysManPrinter_CreateExpanded';
        }
        $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
    }
}
}