Solved

vbscript help

Posted on 2013-05-23
11
399 Views
Last Modified: 2013-06-04
I have created this script that will reside on the server, it will run from a server account.  The point of this script is that it will be a schedule task, it will check the txt file every 15 minutes and if it the file has a computer name it will check against active directory...if it finds it..it will install McAfee, after its done it it reverts back the original computers.txt file to blank until some one puts another computer name on it again....
MY question is,,,is this correct what do i need to fix it and if some one could help me out on log files such as after its done it creates a text file of the out put code..also i was wondering if i don't have permissions to the server to run as a share, is there a way to copy the file to the local machine and execute it from there....any help would be appreciated...

'This will check Active Directory for a computer

Const ADS_SCOPE_SUBTREE = 2
Const ForReading = 1

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection


objCommand.Properties("Page Size") = 1000

objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt")


Do Until objFile.AtEndOfStream
    strComputer = objFile.ReadLine
    objCommand.CommandText = "SELECT Name FROM 'LDAP://dc=microsoft,dc=contoso,dc=com' " & _
        "WHERE objectCategory='computer' AND Name = '" & strComputer & "'"
    Set objRecordset = objCommand.Execute
    If objRecordset.RecordCount = 0 Then
        Wscript.Echo strComputer & " does not exist."
    Else
      ReturnValue=Install(strComputer)
        'Wscript.Echo strComputer & " is in Active Directory."
       Wscript.Echo "ReturnValue = " & ReturnValue
    End If
Loop


'this code will load MaCafee
'Install Software on a Remote Computer

Function Install(strComputer)
Const wbemImpersonationLevelDelegate = 4

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer ("NOSTROVOS", "root\cimv2")

objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install("\\NOSTROVOS\smspackages$\MCafee\4_6_FramePkg_Install_for_MS_Windows_20130211.exe",,True)
Install=ErrReturn
End Function




'Last step in the script

'Create a new file after everything is done
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Scripts\Computers.txt")
0
Comment
Question by:erwin_miranda
  • 6
  • 4
11 Comments
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39193300
Are you running McAfee ePolicy Orchestrator?  This should remove the need for your scripts
0
 

Author Comment

by:erwin_miranda
ID: 39194142
I am but its something else we are trying to do..
0
 

Author Comment

by:erwin_miranda
ID: 39200544
I've requested that this question be deleted for the following reason:

It did not make anysense..and the script is not completed
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39200545
Sorry I wasn't notified with your response. What are you trying to do other than deploying the agent etc?
0
 

Author Comment

by:erwin_miranda
ID: 39200783
Other than automate the process and not have a need for the McAfee policy administrators or myself have to do..nothing...but again if you want the points, they are yours..u responded.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39203128
See the confusing thing for me is, epo should automatically deploy when a new machine appears in active directory. In other words you should not have to do anything anyway.
I'd like to answer this properly before getting any points ;-)
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39203129
Do you have ad sync on?
0
 

Author Comment

by:erwin_miranda
ID: 39210603
Okay...come to find out and apparently I am not a McAfee Admin...the people that are Mcafee Admin do not administrative priviliges..so I need the script..or help with it..
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39212145
Ok I understand your predicament. Now I'm not trying to be difficult but it seems you are trying to mimic what epo does. My concern it's with ongoing Maintenance. Do the agents automatically register with epo after installing using your script?
Instead of giving admin permissions to the McAfee guys, work with them to set up an automated task and enter your credentials (or a specific admin one set up by you for this purpose) and save the username And hidden password as part of the task. It's that a viable option?
More than happy to help with the script but I wanted us clear on the consequences of doing so.
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 200 total points
ID: 39218135
Going down the script route:
You are going to need to make sure you're installing the right version / architecture of McAfee for the machine.  It looks like you're assuming it's Windows and relying on the executable to determine 32/64bit architecture.  
Are you also planning to notify the McAfee guys when you do install a new machine? Are you sure that the new machine will be placed in the right "group" for policy administration?
Adding in a log file is easy, just requires you to have a text file you append to and add in your logs between lines of code.  A simple solution would be to create a simple function at the bottom of your script that takes an input, which is the log text, and outputs to a file.  You can build on that later if need be
You may want to include email notification when your install fails for whatever reason (can't access file share, can't access remote machine etc etc)
I'm sure there's other issues you'll come across going down this path that really ePO does for you... sorry to bang on about it but I don't see the point in reinventing the wheel, unless I"m missing something??
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now