Get Remote Server Environment Variables

Problem: We have Cobol applications that run from many servers (mainly 2003 server) on our network. Many, if not all of these applications use environment variables for installation.

Question: From one workstation can you compile a complete list of environment variables from a list of known remote servers? Optimally, I would like to do this in Batch, VBS, or Powershell.

Answer: In VBS

GetEnvironment("[RemoteServersName]") Function GetEnvironment(ServerName) strComputer = ServerName Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objSWbemServices = objSWbemLocator.ConnectServer _ (strComputer, "root\cimv2", "[ValidLogonName]", "[PasswordForLogonName]") objSWbemServices.Security_.ImpersonationLevel = 3 Set colVar = objSWbemServices.ExecQuery( _ "Select * from Win32_Environment") For Each objVar in colVar WScript.StdOut.Write("Server Name: " & ServerName & VBNewLine) WScript.StdOut.Write("Description: " & objVar.Description & VBNewLine) WScript.StdOut.Write("Name: " & objVar.Name & VBNewLine) WScript.StdOut.Write("System Variable: " & objVar.SystemVariable & VBNewLine) WScript.StdOut.Write("User Name: " & objVar.UserName & VBNewLine) WScript.StdOut.Write("Variable Value: " & objVar.VariableValue & VBNewLine & VBNewLine) Next End Function 
+4
source share
2 answers

Not tried, but you can check this one . examples are vbscript, changing strComputer to the IP address of your remote and see how this happens. For many remote hosts, use a for loop.

+4
source

Here is the powershell command:

 gwmi win32_environment -computername dc1.acme.com 

And if you want a condensed version:

 gwmi win32_environment -computername dc1.acme.com |select name,variablevalue |ft -auto 
+7
source

All Articles