获取远程服务器环境变量 [英] Get remote servers environment variables
问题描述
问题:我们有Cobol应用程序,它们从网络上的许多服务器(主要是Server 2003)运行.这些应用程序中有很多(如果不是全部)都使用环境变量进行设置.
The problem: We have Cobol applications that run from many servers (mostly server 2003) on our network. Many if not all of these applications use environment variables for there setting.
问题:您可以从一个工作站上从已知的远程远程服务器列表中收集完整的环境变量列表吗?理想情况下,我想在Batch,VBS或Powershell中执行此操作.
The Question: From one workstation can you gather the full list of environment variables from a list of known servers remote? Optimally i would like to do this in Batch, VBS, or the Powershell.
答案:在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
推荐答案
Have not tried it, but you can check this out. the examples is vbscript, change strComputer to the IP address of your remote and see how it goes. For many remote hosts, use a for loop.
这篇关于获取远程服务器环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!