ObjectFilesHandling/Import-ITIObject.ps1

<#
.SYNOPSIS
    Imports all the .txt files to the specified container
.DESCRIPTION
    Joins all the .txt files in the specified directory, imports the objects to the database and compiles the imported objects
.EXAMPLE
    Import-ITIObject -ContainerName bccontainer -SourcePath ~/MyProject/Apps
.NOTES
    The command uses commands from NavContainerHelper to import and compile the objects
#>

function Import-ITIObject {
    [CmdletBinding()]
    param (
        # Container to import the objects to
        [Parameter(Mandatory=$true)]
        [string] $ContainerName,
        # Directory where the .txt objects are stored
        [string] $SourcePath = './Apps'
    )
    if(IsDirectory($SourcePath)) {
        $objectFilePath = (NewTempFile).FullName
        Join-ITIObjectsTxtFile -SourcePath $SourcePath -Destination $objectFilePath
    } else {
        $objectFilePath = $SourcePath
    }
    Import-ObjectsToNavContainer -containerName $ContainerName -objectsFile $objectFilePath
    Compile-ObjectsInNavContainer -containerName $ContainerName
}
Export-ModuleMember -Function Import-ITIObject