Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Need help getting VBScript to run remotely

$
0
0

I have a VBScript that runs fine locally but I also need to run it remotely on our network. I've tried using the code on this page http://technet.microsoft.com/en-us/library/ee692838.aspx#EBAA but I get an error. PowerShell in not an option because of security constraints. I have a txt file that lists all of our computers and I would like this script to read that txt file, run this script and then output the information into another txt file.

'Declare varibles
	Dim strComputer, objWMIService, colItems, MyTime	
	Dim oNetwork, sLocal, oFSO, oTS, objFile

	Set oNetwork = CreateObject("WScript.Network")
	sLocal = oNetwork.ComputerName
 	Set oFSO = CreateObject("Scripting.FileSystemObject")

'Save output file here
	Set oTS = oFSO.CreateTextFile("" & sLocal & ".txt")

	On Error Resume Next

'Returns system's current time
	MyTime = Time

'Print today's date
	Function dateFunction()
		date = dateFunction()
	End Function

'Get the serial number and computer name
	strComputer = "."
	Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _& strComputer & "\root\cimv2")

'Find serial number
	Set colSMBIOS = objWMIService.ExecQuery _
    		("Select * from Win32_SystemEnclosure")

'Find computer name
	Set objNetwork = WScript.CreateObject("WScript.Network")
		ComputerName = objNetwork.ComputerName

'Assign information to a variable
	For Each objSMBIOS in colSMBIOS
    		CN = "Computer Name: " & ComputerName
		SN = "Serial Number: " & objSMBIOS.SerialNumber    
	Next

'determine the IP address of a computer
	Set IPConfigSet = objWMIService.ExecQuery _
    		("Select IPAddress from Win32_NetworkAdapterConfiguration ")
	For Each IPConfig in IPConfigSet
    		If Not IsNull(IPConfig.IPAddress) Then 
        		For i=LBound(IPConfig.IPAddress) _
            			to UBound(IPConfig.IPAddress)
                			IP = "IP Address: " & IPConfig.IPAddress(i)
        		Next
    		End If
	Next

'Find MAC	
	Set colItems = objWMIService.ExecQuery _
		("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
			For Each objItem in colItems
				mac = "MAC Address:  " & objItem.MACAddress 
			Next

'Printout information
	oTS.WriteLine "Today is: " & date & VbCrLf & Time
	oTS.WriteLine "" & CN
	oTS.WriteLine "" & SN
	oTS.WriteLine "" & IP
	oTS.WriteLine "" & MAC
	oTS.WriteLine
	oTS.WriteLine "INSTALLED HOTFIXES"
	oTS.WriteLine 

'Query system to installed KB's
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering",,48)
	For Each objItem in colItems
 		oTS.WriteLine "" & objItem.HotFixID
 		'oTS.WriteLine "ServicePackInEffect: " & _
  		objItem.ServicePackInEffect
		oTS.WriteLine
	Next

'Print out list of installed software
	oTS.WriteLine
	oTS.WriteLine "INSTALLED SOFTWARE"
	oTS.WriteLine

'Query system for installed software
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Product",,48)
	For Each objItem in colItems
 		oTS.WriteLine "Caption: " & objItem.Caption
 		oTS.WriteLine "Version: " & objItem.Version
 		oTS.WriteLine
	Next


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>