Environment:
Windows 2016 Standard
Windows 10 Pro
PowerShell 5.1
Anything glaringly wrong with following PowerShell script? It runs fine with no errors but doesn't actually set/create the environment variable.
$session = New-PSSession -ComputerName $hostName -Credential $cred
$sspSharedConnStr = Invoke-Command -Session $session -ScriptBlock{[Environment]::GetEnvironmentVariable("hello_world", 'Machine')}
if ($null -eq $sspSharedConnStr) {
$sspSharedConnStr = "Server=$dbServer1;Database=$database1;User ID=$username;Password=$password;MultipleActiveResultSets=true;TrustServerCertificate=true"
Invoke-Command -Session $session -ScriptBlock{[Environment]::SetEnvironmentVariable("hello_world", $sspSharedConnStr, 'Machine')}
}