functions/Set-ProjectParent.ps1

<#
.SYNOPSIS
Updates parent for existing project.
  
.DESCRIPTION
Moves a project into a new parent by providing the source and target Project IDs.
  
.EXAMPLE
Set-ProjectParent SourceProjectID TargetParentProjectID
#>


Function Set-ProjectParent
{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [int]$SourceProjectID,
        [Parameter(Mandatory=$true)]
        [int]$ParentProjectID
    )

    $uri = $CDXSERVER + "/x/projects/" + $SourceProjectID

    $JSON = ConvertTo-Json @{
        parentId = $ParentProjectID
    }

    $MoveProject = Invoke-RestMethod -Uri $uri -Method Put -Body $JSON -Headers $headers -ContentType "application/json"
    Write-Verbose ( $MoveProject | Format-Table | Out-String )
}