Question

Asked on 2011-05-09 at 09:22:32ID: 27360742

Pull computer names from AD, and NET SEND to list.

by: orhs500

Rating9.3Excellent

I have a script that currently pulls all of the computer names in Active Directory, and puts them into a spreadsheet. What I am having trouble with now, is figuring out how to send a NET SEND message to all of the computers in that list. Any help would be appreciated.

Here is the script I currently have.

[code]
Const ADS_SCOPE_SUBTREE = 2

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add

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") = 100
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
    "SELECT Name FROM " _
        & "'LDAP://dc=****,dc=***' WHERE " _
            & "objectCategory='computer'"  
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
x = 1

Do Until objRecordSet.EOF
    objExcel.Cells(x, 1).Value = _
        objRecordSet.Fields("Name").Value
   
    x = x + 1
    objRecordSet.MoveNext
Loop

Set objRange = objExcel.Range("A1")
objRange.Activate

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()

[/code]

Related Solutions

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution

View This Solution - Start Your 30 Day Free Trial
Zone
general
Tags
net send vbscript
Participating Experts
2
Solution Grade
A

Replies

 by: paulmacd

Posted on 2011-05-09 at 09:34:19ID: 36812509

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: orhs

Posted on 2011-05-09 at 10:38:36ID: 36812510

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: RobSampson

Posted on 2011-05-09 at 21:25:23ID: 36812511

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: orhs

Posted on 2011-05-10 at 08:34:57ID: 36812512

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: RobSampson

Posted on 2011-05-10 at 15:58:36ID: 36812513

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Log In

Forgot your password?Sign up

Top Experts

  1. mplungjan

    1,840

    0 points yesterday

    Profile

BrowseAre you an Expert?