Affaan Abyaz
asked on
Use different credenatils to pull the report from other domain servers
attached script works well in the same domain servers but I want to use different credential to be used by this script in order to run against another domain servers.. we have multiple domains in a same forest and i need some help in updating the script...
DiskSpace-Report-HTML.txt
DiskSpace-Report-HTML.txt
ASKER
I think I missed to mention that its a VBScript.. Please save it with .vbs extension to check on the code.
Hi, try changing this line:
to this
then change remoteuser and remotepassword as required.
Rob.
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
to this
Set objLocator=CreateObject("WbemScripting.SWbemLocator")
Set objWMIService=objLocator.ConnectServer(strComputer, "root\default", "domain\remoteuser", "remotepassword")
then change remoteuser and remotepassword as required.
Rob.
ASKER
by anyway can we encrypt the credentials ?
Please note that I will have to schedule it on the server as a job aswell..
Please note that I will have to schedule it on the server as a job aswell..
ASKER
Hi Rob,
I have updated the script and executed the same from different domain.. its did not pop-up any error message and executing but in the report its not giving any values either.. attached is the report
2015-11-02_18-52-21.png
I have updated the script and executed the same from different domain.. its did not pop-up any error message and executing but in the report its not giving any values either.. attached is the report
2015-11-02_18-52-21.png
Sorry, it wasn't meant to have root\default in it. It should be root\CimV2
As for encrypting the password, you can't really do that in VBScript. What you could do to make it a bit more secure, is have the script accept the username and password as script parameters, and then add those parameters to the scheduled task. To make it a bit more secure, if the script did some known string manipulation on the passed parameters, you can specify a reverse engineered parameter to the script, and have the script manipulate that into the correct password.
For example, if your password was mypass you could pass
90!33
to the script, and in the script have this
and strPassword would contain the correct password. This way, the password can only be sniffed out at run time, which is unlikely, but not impossible.
Regards,
Rob.
Set objLocator=CreateObject("WbemScripting.SWbemLocator")
Set objWMIService=objLocator.ConnectServer(strComputer, "root\CimV2", "domain\remoteuser", "remotepassword")
As for encrypting the password, you can't really do that in VBScript. What you could do to make it a bit more secure, is have the script accept the username and password as script parameters, and then add those parameters to the scheduled task. To make it a bit more secure, if the script did some known string manipulation on the passed parameters, you can specify a reverse engineered parameter to the script, and have the script manipulate that into the correct password.
For example, if your password was mypass you could pass
90!33
to the script, and in the script have this
strPassword = ""
For intChr = 1 To Len(strPassed)
If intChr = 1 Then
strPassword = Chr(Asc(Mid(strPassed, intChr, 1)) + 64)
Else
strPassword = strPassword & Chr(Asc(Mid(strPassed, intChr, 1)) + 64)
End If
Next
and strPassword would contain the correct password. This way, the password can only be sniffed out at run time, which is unlikely, but not impossible.
Regards,
Rob.
ASKER
Thanks Rob.. that works well.. I am able to use it with different credentails and works well.. one last query and its about the same thing hidding the credentails in vbscript.. I am thinking about coverting vb to exe and the problem I found is that it has a variable set for the location. Line 53 says OutputDir = "C:\HP\Wintel\Admin_Tasks\ DiskSpace" and if I replace it with ".\" in order to check for servers.txt and my outfiles to be created in the same folder where as I am running this script, it is not working...
could you please help me in fixing this ? and then we can have this questions closed gracefully :D
could you please help me in fixing this ? and then we can have this questions closed gracefully :D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Rob. As always your solution works.
Open in new window