exports/Install-SysManSystem.ps1

<#
.Synopsis
Installs one or more systems on one or more clients
.Description
Installs one or more systems on one or more clients
.Link
https://docs.microsoft.com/en-us/powershell/module/sysman.webapi/install-sysmansystem
#>

function Install-SysManSystem {
[OutputType('SysMan.Powershell.Models.IDistributionInstallationResult', 'SysMan.Powershell.Models.IApiErrorMessage')]
[CmdletBinding(DefaultParameterSetName='Install', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[SysMan.Powershell.Description('Installs one or more systems on one or more clients')]
param(
    [Parameter(ParameterSetName='Install', ValueFromPipeline, HelpMessage='Represent the information required to install one or more systems on one or more clients')]
    [SysMan.Powershell.Category('Body')]
    [SysMan.Powershell.Models.IInstallSystemOnTargetV2Command]
    ${Cmd},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='The date the installation should take place')]
    [SysMan.Powershell.Category('Body')]
    [System.DateTime]
    ${ExecuteDate},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='The type of installation. If specified all application has to support the provided installation type (exeample: If Required then all applications has to support mandatory installation). If the installation type is not supported by all applications the call will fail.If no value is provided the installation will fallback according to the following rules:<ol><li>If application supports mandatory installation then Required is used.</li><li>If application supports non mandatory installation then Available is used.</li><li>If none of the above the call will fail</li></ol>')]
    [SysMan.Powershell.Category('Body')]
    [System.String]
    ${InstallationType},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='The id of the systems that should be installed on the provided targets.')]
    [SysMan.Powershell.Category('Body')]
    [System.Int64[]]
    ${Systems},

    [Parameter(ParameterSetName='InstallExpanded', Mandatory, HelpMessage='The id of the targets (clients or users) to install the systems on. Have to contain one or more id')]
    [SysMan.Powershell.Category('Body')]
    [System.Int64[]]
    ${Targets},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='If the installation of system should be based on existing installations on a target. Expects an id of the targetThis value is only honored if system list is empty. If any item is added to the system list the system in that list will be usedinstead of the systems that is currently installed on the template target.')]
    [SysMan.Powershell.Category('Body')]
    [System.Int64]
    ${TemplateTargetId},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='If direct membership should be used for this software installation. Will override the default direct membershipcalculation done by SysMan (which is based on configuration) and should rarely be used by external systems.')]
    [SysMan.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    ${UseDirectMembership},

    [Parameter(ParameterSetName='InstallExpanded', HelpMessage='If wake on lan should be used on the clients (if any) that will get the installed softwares,If null then the value provided in the SysMan configuration will be used.')]
    [SysMan.Powershell.Category('Body')]
    [System.Management.Automation.SwitchParameter]
    ${UseWakeOnLan},

    [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 = @{
            Install = 'SysMan.WebApi.private\Install-SysManSystem_Install';
            InstallExpanded = 'SysMan.WebApi.private\Install-SysManSystem_InstallExpanded';
        }
        $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
    }
}
}