functions/Import-ProjectsFromCSV.ps1
<#
.SYNOPSIS Create project based on a CSV file to be imported. .DESCRIPTION Used to import a list of project identifiers. This is useful for onboarding new environments or labs. .EXAMPLE Import-ProjectsFromCSV .\myfile.csv #> Function Import-ProjectsFromCSV { [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string]$CSVFilePath ) $uri = $CDXSERVER + "/api/projects" $CSVArray = Import-Csv $CSVFilePath $CSVArray | ForEach-Object{ $JSON = ConvertTo-Json @{ name = $_.projectname } $CreateProject = Invoke-RestMethod -Uri $uri -Method Put -Body $JSON -Headers $headers -ContentType "application/json" Write-Verbose ( $CreateProject | Format-Table | Out-String ) } } |