M
Mad Scientist Jr
I found out how to enumerate all machines on a domain:
Dim sDomainName As String
Dim oDomain As Variant
Dim oComputer As Variant
Dim iRow As Long
Dim sCol As String
iRow = ActiveCell.Row
sCol = NumToColumn(ActiveCell.Column)
sDomainName = "mydomain"
Set oDomain = GetObject("WinNT://" & sDomainName)
oDomain.Filter = Array("computer")
For Each oComputer In oDomain
Worksheets(ActiveSheet.Name).Cells(CStr(iRow), sCol).Value =
oComputer.Name
iRow = iRow + 1
Next
Exit Sub
and if a machine is up
Function UpDownMachine(MachineName) As Boolean
Dim Ping As Variant
Dim Result As Variant
Set Ping = CreateObject("DSPing.Ping")
Result = Ping.DoPing(MachineName)
If Result = 3 Then
UpDownMachine = False
ElseIf Result = 4 Then
UpDownMachine = False
Else
UpDownMachine = True
End If
End Function ' UpDownMachine
however, how would you tell if the machine in question is a print
server, as opposed to someone's personal workstation?
Much appreciated...
PS the code below seems to retrieve user names and groups and might
help with this, I haven't tried it yet:
1. Gary Lumpkin
View profile
I am having a problem setting an Excel column to set vertical
alignment to automatically justify. Any help would be greatly
appreciated. The area is labeled " Problem Area" Thanks Gary
'~~~Author Gary Lumpkin '~~~Date 1/14/2000 '~~~Non Production On
Error Resume Next Dim MsgBoxTip Dim objDom Dim objSrv Dim objXL Dim
objFS Dim objUsrId Dim objUsr Dim strGrp Dim objGrp Dim strGrpe Dim
objColGrp Dim xlJustify Dim List MsgBoxTip = "Server Auditor Beta 2"
objDom = InputBox("Which server do you Audit? ", MsgBoxTip) If
IsEmpty(objDom) Then Wscript.Echo "Audit Canceled!!" wscript.Quit
end If Set objSrv = GetObject("WinNT://" & objDom) Set objXL =
Wscript.CreateObject("Excel.Application") Set objFS =
Wscript.CreateObject("Scripting.FileSystemObject") setupXL()
objSrv.Filter = Array("user") For Each objUsrId in objSrv Set objUsr
= GetObject("WinNT://" & objDom &"/"& objUsrId.Name ) 'Layout
Spreadsheet Local Users objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate objXL.Activecell.Value = "" &
objUsrId.Name objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.FullName
objXL.Activecell.offset(0,1).Activate objXL.Activecell.Value = "" &
objUsrId.Description objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.AccountDisabled
objXL.Activecell.offset(0,1).Activate Set strGrp =
objFS.OpenTextFile("c:\temp\Grptxt.txt", 2, True) For Each
objGrp In objUsr.Groups strGrp.write("" & objGrp.Name & ",
" ) Next strGrp.Close Set strGrpe =
objFS.OpenTextFile("c:\temp\Grptxt.txt", 1, True) objColGrp =
strGrpe.readall objXL.Activecell.Value = "" & objColGrp
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-6).Activate next
objXL.Sheets("Sheet1").Select objXL.Sheets("Sheet1").Name = "Local
Accts" objXL.Sheets("Sheet2").Select objXL.Sheets("Sheet2").Name =
"Local Groups" objXL.ActiveSheet.range("A3").Activate
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Layout Spreadsheet Local Groups and Members objSrv.Filter =
Array("group") For Each objGrp In objSrv objXL.Activecell.Value = ""
& objDom objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objGrp.Name
objXL.Activecell.offset(0,1).Activate For each objUsrId in
objGrp.Members List = List & ", " & objUsrId.Name Next
objXL.Activecell.Value = "" & List
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-3).Activate Next
objXL.Sheets("Sheet3").Select objXL.Sheets("Sheet3").Name =
"Policies" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function setupXL() objXL.Visible = TRUE objXL.WorkBooks.Add
objXL.Columns(1).ColumnWidth = 25 objXL.Columns(2).ColumnWidth =
25 objXL.Columns(3).ColumnWidth = 25 objXL.Columns(4).ColumnWidth
= 25 objXL.Columns(5).ColumnWidth = 8 objXL.Columns(6).ColumnWidth
= 25 objXL.Cells(1, 1).Value = "Server" objXL.Cells(1, 2).Value =
"Local Accounts" objXL.Cells(1, 3).Value = "Full Name"
objXL.Cells(1, 4).Value = "Description" objXL.Cells(1, 5).Value =
"Disabled" objXL.Cells(1, 6).Value = "Group Membership"
'~~~~~~Problem Area~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'objXL.Range("C:C").select 'objXL.Range.Selection.VerticalAlignment
= xlVAlignJustify
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objXL.Range("A1:Z1").Select objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet2").Select objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25 objXL.Columns(3).ColumnWidth =
25 objXL.Cells(1, 1).Value = "Server" objXL.Cells(1, 2).Value =
"Local Group" objXL.Cells(1, 3).Value = "Members"
objXL.Range("A1:Z1").Select objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet1").Select objXL.ActiveSheet.range("A3").Activate
End Function
More options Jan 19 2000, 3:00 am
Newsgroups: microsoft.public.scripting.wsh
From: "Gary Lumpkin" <[email protected]>
Date: 2000/01/19
Subject: Syntax problem formating Excel Column - audit script
Reply to author | Forward | Print | Individual message | Show original
| Report this message | Find messages by this author
I am having a problem setting an Excel column to set vertical
alignment to
automatically justify.
Any help would be greatly appreciated. The area is labeled " Problem
Area"
Thanks
Gary
'~~~Author Gary Lumpkin
'~~~Date 1/14/2000
'~~~Non Production
On Error Resume Next
Dim MsgBoxTip
Dim objDom
Dim objSrv
Dim objXL
Dim objFS
Dim objUsrId
Dim objUsr
Dim strGrp
Dim objGrp
Dim strGrpe
Dim objColGrp
Dim xlJustify
Dim List
MsgBoxTip = "Server Auditor Beta 2"
objDom = InputBox("Which server do you Audit? ", MsgBoxTip)
If IsEmpty(objDom) Then
Wscript.Echo "Audit Canceled!!"
wscript.Quit
end If
Set objSrv = GetObject("WinNT://" & objDom)
Set objXL = Wscript.CreateObject("Excel.Application")
Set objFS = Wscript.CreateObject("Scripting.FileSystemObject")
setupXL()
objSrv.Filter = Array("user")
For Each objUsrId in objSrv
Set objUsr = GetObject("WinNT://" & objDom &"/"& objUsrId.Name )
'Layout Spreadsheet Local Users
objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.Name
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.FullName
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.Description
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.AccountDisabled
objXL.Activecell.offset(0,1).Activate
Set strGrp = objFS.OpenTextFile("c:\temp\Grptxt.txt", 2, True)
For Each objGrp In objUsr.Groups
strGrp.write("" & objGrp.Name & ", " )
Next
strGrp.Close
Set strGrpe = objFS.OpenTextFile("c:\temp\Grptxt.txt", 1, True)
objColGrp = strGrpe.readall
objXL.Activecell.Value = "" & objColGrp
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-6).Activate
next
objXL.Sheets("Sheet1").Select
objXL.Sheets("Sheet1").Name = "Local Accts"
objXL.Sheets("Sheet2").Select
objXL.Sheets("Sheet2").Name = "Local Groups"
objXL.ActiveSheet.range("A3").Activate
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Layout Spreadsheet Local Groups and Members
objSrv.Filter = Array("group")
For Each objGrp In objSrv
objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objGrp.Name
objXL.Activecell.offset(0,1).Activate
For each objUsrId in objGrp.Members
List = List & ", " & objUsrId.Name
Next
objXL.Activecell.Value = "" & List
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-3).Activate
Next
objXL.Sheets("Sheet3").Select
objXL.Sheets("Sheet3").Name = "Policies"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function setupXL()
objXL.Visible = TRUE
objXL.WorkBooks.Add
objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25
objXL.Columns(3).ColumnWidth = 25
objXL.Columns(4).ColumnWidth = 25
objXL.Columns(5).ColumnWidth = 8
objXL.Columns(6).ColumnWidth = 25
objXL.Cells(1, 1).Value = "Server"
objXL.Cells(1, 2).Value = "Local Accounts"
objXL.Cells(1, 3).Value = "Full Name"
objXL.Cells(1, 4).Value = "Description"
objXL.Cells(1, 5).Value = "Disabled"
objXL.Cells(1, 6).Value = "Group Membership"
'~~~~~~Problem Area~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'objXL.Range("C:C").select
'objXL.Range.Selection.VerticalAlignment = xlVAlignJustify
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objXL.Range("A1:Z1").Select
objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet2").Select
objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25
objXL.Columns(3).ColumnWidth = 25
objXL.Cells(1, 1).Value = "Server"
objXL.Cells(1, 2).Value = "Local Group"
objXL.Cells(1, 3).Value = "Members"
objXL.Range("A1:Z1").Select
objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet1").Select
objXL.ActiveSheet.range("A3").Activate
End Function
Dim sDomainName As String
Dim oDomain As Variant
Dim oComputer As Variant
Dim iRow As Long
Dim sCol As String
iRow = ActiveCell.Row
sCol = NumToColumn(ActiveCell.Column)
sDomainName = "mydomain"
Set oDomain = GetObject("WinNT://" & sDomainName)
oDomain.Filter = Array("computer")
For Each oComputer In oDomain
Worksheets(ActiveSheet.Name).Cells(CStr(iRow), sCol).Value =
oComputer.Name
iRow = iRow + 1
Next
Exit Sub
and if a machine is up
Function UpDownMachine(MachineName) As Boolean
Dim Ping As Variant
Dim Result As Variant
Set Ping = CreateObject("DSPing.Ping")
Result = Ping.DoPing(MachineName)
If Result = 3 Then
UpDownMachine = False
ElseIf Result = 4 Then
UpDownMachine = False
Else
UpDownMachine = True
End If
End Function ' UpDownMachine
however, how would you tell if the machine in question is a print
server, as opposed to someone's personal workstation?
Much appreciated...
PS the code below seems to retrieve user names and groups and might
help with this, I haven't tried it yet:
1. Gary Lumpkin
View profile
I am having a problem setting an Excel column to set vertical
alignment to automatically justify. Any help would be greatly
appreciated. The area is labeled " Problem Area" Thanks Gary
'~~~Author Gary Lumpkin '~~~Date 1/14/2000 '~~~Non Production On
Error Resume Next Dim MsgBoxTip Dim objDom Dim objSrv Dim objXL Dim
objFS Dim objUsrId Dim objUsr Dim strGrp Dim objGrp Dim strGrpe Dim
objColGrp Dim xlJustify Dim List MsgBoxTip = "Server Auditor Beta 2"
objDom = InputBox("Which server do you Audit? ", MsgBoxTip) If
IsEmpty(objDom) Then Wscript.Echo "Audit Canceled!!" wscript.Quit
end If Set objSrv = GetObject("WinNT://" & objDom) Set objXL =
Wscript.CreateObject("Excel.Application") Set objFS =
Wscript.CreateObject("Scripting.FileSystemObject") setupXL()
objSrv.Filter = Array("user") For Each objUsrId in objSrv Set objUsr
= GetObject("WinNT://" & objDom &"/"& objUsrId.Name ) 'Layout
Spreadsheet Local Users objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate objXL.Activecell.Value = "" &
objUsrId.Name objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.FullName
objXL.Activecell.offset(0,1).Activate objXL.Activecell.Value = "" &
objUsrId.Description objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.AccountDisabled
objXL.Activecell.offset(0,1).Activate Set strGrp =
objFS.OpenTextFile("c:\temp\Grptxt.txt", 2, True) For Each
objGrp In objUsr.Groups strGrp.write("" & objGrp.Name & ",
" ) Next strGrp.Close Set strGrpe =
objFS.OpenTextFile("c:\temp\Grptxt.txt", 1, True) objColGrp =
strGrpe.readall objXL.Activecell.Value = "" & objColGrp
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-6).Activate next
objXL.Sheets("Sheet1").Select objXL.Sheets("Sheet1").Name = "Local
Accts" objXL.Sheets("Sheet2").Select objXL.Sheets("Sheet2").Name =
"Local Groups" objXL.ActiveSheet.range("A3").Activate
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Layout Spreadsheet Local Groups and Members objSrv.Filter =
Array("group") For Each objGrp In objSrv objXL.Activecell.Value = ""
& objDom objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objGrp.Name
objXL.Activecell.offset(0,1).Activate For each objUsrId in
objGrp.Members List = List & ", " & objUsrId.Name Next
objXL.Activecell.Value = "" & List
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-3).Activate Next
objXL.Sheets("Sheet3").Select objXL.Sheets("Sheet3").Name =
"Policies" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function setupXL() objXL.Visible = TRUE objXL.WorkBooks.Add
objXL.Columns(1).ColumnWidth = 25 objXL.Columns(2).ColumnWidth =
25 objXL.Columns(3).ColumnWidth = 25 objXL.Columns(4).ColumnWidth
= 25 objXL.Columns(5).ColumnWidth = 8 objXL.Columns(6).ColumnWidth
= 25 objXL.Cells(1, 1).Value = "Server" objXL.Cells(1, 2).Value =
"Local Accounts" objXL.Cells(1, 3).Value = "Full Name"
objXL.Cells(1, 4).Value = "Description" objXL.Cells(1, 5).Value =
"Disabled" objXL.Cells(1, 6).Value = "Group Membership"
'~~~~~~Problem Area~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'objXL.Range("C:C").select 'objXL.Range.Selection.VerticalAlignment
= xlVAlignJustify
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objXL.Range("A1:Z1").Select objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet2").Select objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25 objXL.Columns(3).ColumnWidth =
25 objXL.Cells(1, 1).Value = "Server" objXL.Cells(1, 2).Value =
"Local Group" objXL.Cells(1, 3).Value = "Members"
objXL.Range("A1:Z1").Select objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet1").Select objXL.ActiveSheet.range("A3").Activate
End Function
More options Jan 19 2000, 3:00 am
Newsgroups: microsoft.public.scripting.wsh
From: "Gary Lumpkin" <[email protected]>
Date: 2000/01/19
Subject: Syntax problem formating Excel Column - audit script
Reply to author | Forward | Print | Individual message | Show original
| Report this message | Find messages by this author
I am having a problem setting an Excel column to set vertical
alignment to
automatically justify.
Any help would be greatly appreciated. The area is labeled " Problem
Area"
Thanks
Gary
'~~~Author Gary Lumpkin
'~~~Date 1/14/2000
'~~~Non Production
On Error Resume Next
Dim MsgBoxTip
Dim objDom
Dim objSrv
Dim objXL
Dim objFS
Dim objUsrId
Dim objUsr
Dim strGrp
Dim objGrp
Dim strGrpe
Dim objColGrp
Dim xlJustify
Dim List
MsgBoxTip = "Server Auditor Beta 2"
objDom = InputBox("Which server do you Audit? ", MsgBoxTip)
If IsEmpty(objDom) Then
Wscript.Echo "Audit Canceled!!"
wscript.Quit
end If
Set objSrv = GetObject("WinNT://" & objDom)
Set objXL = Wscript.CreateObject("Excel.Application")
Set objFS = Wscript.CreateObject("Scripting.FileSystemObject")
setupXL()
objSrv.Filter = Array("user")
For Each objUsrId in objSrv
Set objUsr = GetObject("WinNT://" & objDom &"/"& objUsrId.Name )
'Layout Spreadsheet Local Users
objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.Name
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.FullName
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.Description
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objUsrId.AccountDisabled
objXL.Activecell.offset(0,1).Activate
Set strGrp = objFS.OpenTextFile("c:\temp\Grptxt.txt", 2, True)
For Each objGrp In objUsr.Groups
strGrp.write("" & objGrp.Name & ", " )
Next
strGrp.Close
Set strGrpe = objFS.OpenTextFile("c:\temp\Grptxt.txt", 1, True)
objColGrp = strGrpe.readall
objXL.Activecell.Value = "" & objColGrp
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-6).Activate
next
objXL.Sheets("Sheet1").Select
objXL.Sheets("Sheet1").Name = "Local Accts"
objXL.Sheets("Sheet2").Select
objXL.Sheets("Sheet2").Name = "Local Groups"
objXL.ActiveSheet.range("A3").Activate
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Layout Spreadsheet Local Groups and Members
objSrv.Filter = Array("group")
For Each objGrp In objSrv
objXL.Activecell.Value = "" & objDom
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.Value = "" & objGrp.Name
objXL.Activecell.offset(0,1).Activate
For each objUsrId in objGrp.Members
List = List & ", " & objUsrId.Name
Next
objXL.Activecell.Value = "" & List
objXL.Activecell.offset(0,1).Activate
objXL.Activecell.offset(1,-3).Activate
Next
objXL.Sheets("Sheet3").Select
objXL.Sheets("Sheet3").Name = "Policies"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function setupXL()
objXL.Visible = TRUE
objXL.WorkBooks.Add
objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25
objXL.Columns(3).ColumnWidth = 25
objXL.Columns(4).ColumnWidth = 25
objXL.Columns(5).ColumnWidth = 8
objXL.Columns(6).ColumnWidth = 25
objXL.Cells(1, 1).Value = "Server"
objXL.Cells(1, 2).Value = "Local Accounts"
objXL.Cells(1, 3).Value = "Full Name"
objXL.Cells(1, 4).Value = "Description"
objXL.Cells(1, 5).Value = "Disabled"
objXL.Cells(1, 6).Value = "Group Membership"
'~~~~~~Problem Area~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'objXL.Range("C:C").select
'objXL.Range.Selection.VerticalAlignment = xlVAlignJustify
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
objXL.Range("A1:Z1").Select
objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet2").Select
objXL.Columns(1).ColumnWidth = 25
objXL.Columns(2).ColumnWidth = 25
objXL.Columns(3).ColumnWidth = 25
objXL.Cells(1, 1).Value = "Server"
objXL.Cells(1, 2).Value = "Local Group"
objXL.Cells(1, 3).Value = "Members"
objXL.Range("A1:Z1").Select
objXL.Selection.Font.Bold = True
objXL.Sheets("Sheet1").Select
objXL.ActiveSheet.range("A3").Activate
End Function