functions/Add-ProjectsX.ps1

<#
.SYNOPSIS
  
Create X number of projects.
  
.DESCRIPTION
Used for dev/testing to create multiple projects in one environment. Allows for a base name of the project to be created, but it's optional. All projects will contain a Project # as part of the name.
  
.EXAMPLE
Add-ProjectsX 500
  
#>


Function Add-ProjectsX
{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [Int]
        $NumberOfProjects
        ,
        [String]
        $NewProjectName
    )
    
    $uri = $CDXSERVER + "/api/projects"

    For ($i=1; $i -le $NumberOfProjects; $i++) {
        
        $ProjectNum = $i.ToString()
        $ProjectNum = $ProjectNum.PadLeft(5,"0")

        $JSON = ConvertTo-Json @{
            name = $NewProjectName + " " + $ProjectNum
        }

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