Solved

vbscript help

Posted on 2013-05-23
11
404 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

733 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