?
Solved

vbscript help

Posted on 2013-05-23
11
Medium Priority
?
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 43

Expert Comment

by:Rob
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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 
LVL 43

Expert Comment

by:Rob
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
 
LVL 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Accepted Solution

by:
Rob earned 600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

777 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