AzFilesSmbMIClient.psm1

# AzFilesSmbMIClient.psm1

$moduleRoot = $PSScriptRoot
$dllFolder  = Join-Path $moduleRoot "bin"

# Set AZFILESSMBMICLIENT only if it's not already set to $dllFolder
$currentClient = [Environment]::GetEnvironmentVariable("AZFILESSMBMICLIENT", [EnvironmentVariableTarget]::Machine)
if ($currentClient -ne $dllFolder) {
    [Environment]::SetEnvironmentVariable("AZFILESSMBMICLIENT", $dllFolder, [EnvironmentVariableTarget]::Machine)
}

# Add $dllFolder to system PATH if it's not already included
$currentPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
if ($currentPath -notlike "*$dllFolder*") {
    $newPath = "$currentPath;$dllFolder"
    [Environment]::SetEnvironmentVariable("Path", $newPath, [EnvironmentVariableTarget]::Machine)
}

if ($env:Path -notlike "*$dllFolder*") {
    $env:Path = "$env:Path;$dllFolder"
}