Private/Get-DownloadDirectory.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Get-DownloadDirectory {
    param (
        [Parameter(Mandatory = $True)]
        [String]
        $DownloadDirectory
    )
    
    Write-Host "[Get-DownloadDirectory] $DownloadDirectory"

    if (-not (Test-Path $DownloadDirectory)) {
        Write-Host "Download Dir Does Not Exist, Creating"
        try {
            $DownloadDirectory = New-Item -ItemType Directory -Force -Path $DownloadDirectory -ErrorAction Stop
        } catch {
            Throw '[Get-DownloadDirectory] Failed to create directory'
        }
    }

    Write-Host "[Get-DownloadDirectory] $DownloadDirectory"

    return $DownloadDirectory
}