Check the value of an Environmental Variable on Multiple servers

Here’s one powershell method for how to check the value of an environment variable on multiple servers;

?View Code POWERSHELL
$computers = @("server1", "server2", "server3");
 
foreach ($c in $computers)
{
	 Get-WmiObject -ComputerName $c -Class Win32_Environment -Filter "Username = '<SYSTEM>' AND Name = 'VAR_NAME'";
}

Output will be similar to below…

VariableValue              Name                       UserName
-------------              ----                       --------
SERVER1                  VAR_NAME                    
SERVER2                  VAR_NAME                    
SERVER3                  VAR_NAME                    

Leave a Reply