functions/Import-BlackDuckFromCSV.ps1

<#
.SYNOPSIS
Create Black Duck connectors based on a CSV file to be imported.
  
.DESCRIPTION
Used to create projects with Black Duck connectors, based upon an imported CSV file.
  
.EXAMPLE
Import-BlackDuckFromCSV .\myfile.csv https://samplehostname.blackducksoftware.com/ username@domainname.com password1234
  
#>


Function Import-BlackDuckFromCSV
{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string]$CSVFilePath ,   
        [Parameter(Mandatory=$true)]
        [string]$ToolHostURL,
        [Parameter(Mandatory=$true)]
        [string]$ToolUserName,   
        [Parameter(Mandatory=$true)]
        [string]$ToolPassword   
    )
    
    $CSVArray = Import-Csv $CSVFilePath
    
    $CSVArray | ForEach-Object{
        # Keeping these as separate variables in case we'd like to make them independent or add a prefix later
        $ProjectName = $_.ToolProjectName
        $NewConnectorName = $_.ToolProjectName

        Add-Project $ProjectName
        $CreateConnector = Add-BlackDuckConnector $ProjectName $NewConnectorName $_.ToolProjectName $_.ToolProjectVersion $ToolHostURL $ToolUserName $ToolPassword $_.RefreshTime
        Write-Verbose ( $CreateConnector | Format-Table | Out-String )
    }

}