Public/Set-PegasusAdminPosition.ps1

<#
.SYNOPSIS
Connects to the Microsoft Graph and reads all users. Useful for joining.

.EXAMPLE
Set-PegasusAdminPosition

#>

function Set-PegasusAdminPosition {
    [CmdletBinding()]

    Param
    (
        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $id,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $source = $null,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [Boolean] $archived = $false,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [Nullable[DateTime]] $archivaltime = $null,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $person,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $manager,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $orgunit,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $jobtitle,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $jobcode,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $company,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $location,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $jobtype,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $employeeid,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $employerid,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $costcenter,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [Boolean] $primary,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $startdate,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $enddate,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [Boolean] $autoactive,

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("NotSet", "Activated", "Deactivated")]
        [String] $manualactivation = "NotSet",

        [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
        [NullString] $sourceid = $null,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [NullString] $partition,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable] $customfields
    )
    
    Process {
        $body = @{
            id               = $id
            source           = $source
            archived         = $archived
            archivaltime     = $archivaltime
            person           = $person
            manager          = $manager
            orgunit          = $orgunit
            jobtitle         = $jobtitle
            jobcode          = $jobcode
            company          = $company
            location         = $location
            jobtype          = $jobtype
            employeeid       = $employeeid
            employerid       = $employerid
            costcenter       = $costcenter
            primary          = $primary
            startdate        = $startdate
            enddate          = $enddate
            autoactive       = $autoactive
            manualactivation = $manualactivation
            sourceid         = $sourceid
            partition        = $partition
            customfields     = $customfields
        }

        Invoke-PegasusRequest -Endpoint "/admin/positions/$id" -Method PATCH -Body $body
    }
}