Private/Mount-SmbDrive.ps1

function Mount-SmbDrive {
    <#
    .SYNOPSIS
        Mounts an Azure File Share to a local drive letter using a storage account key.
    .PARAMETER AccountName
        Name of the Azure Storage Account.
    .PARAMETER AccountKey
        Storage account access key.
    .PARAMETER ShareName
        Name of the file share.
    .PARAMETER DriveLetter
        Single letter (A-Z) to mount to.
    .OUTPUTS
        [void]
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$AccountName,

        [Parameter(Mandatory)]
        [string]$AccountKey,

        [Parameter(Mandatory)]
        [string]$ShareName,

        [Parameter(Mandatory)]
        [ValidatePattern('^[A-Za-z]$')]
        [string]$DriveLetter
    )

    $drive   = "${DriveLetter}:"
    $uncPath = "\\${AccountName}.file.core.windows.net\${ShareName}"

    Write-Host "[$(Get-Timestamp)] Mounting '$uncPath' → $drive ..." -ForegroundColor Cyan
    $result = Invoke-NetUse -Arguments @($drive, $uncPath, "/user:Azure\${AccountName}", $AccountKey)
    if ($LASTEXITCODE -ne 0) {
        throw "Failed to mount '$uncPath': $result"
    }
    Write-Host " ✓ Mounted '$drive'." -ForegroundColor Green
}