Functions/Set-Global.ps1

function Set-Global {
    #timestamp of when script is being run
    $script:scriptTimeStamp = Get-Date -UFormat %Y-%m-%d-T%H-%M-%S;

    #set scanned data path for current run
    if($outputDirectory){
         $ScannedDataRoot = "$outputDirectory\PSCloudScannerData";
    } else {
        $documentsPath = [Environment]::GetFolderPath("MyDocuments")
        $ScannedDataRoot = "$documentsPath\PSCloudScannerData";
    }

    if(!(Test-Path $ScannedDataRoot)){
        New-Item -ItemType Directory -Path $ScannedDataRoot | Out-Null
    }
    
    $script:ScannedDataPath = "$ScannedDataRoot\scan_$scriptTimeStamp"
    New-Item -ItemType Directory -Path $ScannedDataPath | Out-Null

    #set the error log file path
    $script:ErrorLogPath = "$ScannedDataPath\Errors.txt";
}