-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.vbs
executable file
·133 lines (116 loc) · 5.02 KB
/
test.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'==========================================================================================
' Write to an Excel file
'==========================================================================================
Dim objXLApp, objXLWb, objXLWs
strFile = "test.xlsx"
Set objShell = CreateObject("Wscript.Shell")
strPath = objShell.CurrentDirectory
Set objXLApp = CreateObject("Excel.Application")
objXLApp.Visible = True
Set objXLWb = objXLApp.Workbooks.Open(strPath & "\" & strFile)
'~~> Working with Sheet1
Set objXLWs = objXLWb.Sheets(1)
intRow = 1
Do Until objXLWs.Cells(intRow,1).Value = ""
Wscript.Echo objXLWs.Cells(intRow,1)
Call UpdateInfo(2,intRow)
intRow = intRow + 1
Loop
objXLWb.Save
'~~> Save as Excel File (xls) to retain format
'objXLWb.SaveAs "C:\test.xlsx"
'~~> File Formats
'51 = xlOpenXMLWorkbook (without macro's in 2007-2010, xlsx)
'52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2010, xlsm)
'50 = xlExcel12 (Excel Binary Workbook in 2007-2010 with or without macro's, xlsb)
'56 = xlExcel8 (97-2003 format in Excel 2007-2010, xls)
objXLWb.Close(SaveChanges=False)
Set objXLWs = Nothing
Set objXLWb = Nothing
objXLApp.Quit
Set objXLApp = Nothing
Sub CheckBitlocker
strComputer = "."
Set objShell = CreateObject("Wscript.Shell")
strEnvSysDrive = objShell.ExpandEnvironmentStrings("%SystemDrive%")
Set objWMIServiceBit = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
Set colItems = objWMIServiceBit.ExecQuery("SELECT * FROM Win32_EncryptableVolume",,48)
For Each objItem in colItems
If objItem.DriveLetter = strEnvSysDrive Then
strDeviceC = objItem.DeviceID
DriveC = "Win32_EncryptableVolume.DeviceID='"&strDeviceC&"'"
Set objOutParams = objWMIServiceBit.ExecMethod(DriveC, "GetProtectionStatus")
If objOutParams.ProtectionStatus = "1" Then
wscript.Echo "Bitlocker is enabled"
Else
wscript.Echo "Bitlocker is disabled"
End if
End If
Next
End Sub
Sub CheckBitlocker2
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_EncryptableVolume",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_EncryptableVolume instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "ProtectionStatus: " & objItem.ProtectionStatus
Next
End Sub
Sub UpdateInfo(intSheet, intRow)
strComputer = objXLWs.Cells(intRow,1)
'Write data to sheet 2
Set objWs = objXLWb.Sheets(intSheet)
Set Network = CreateObject("WScript.Network")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set query_result = objWMI.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
For Each item In query_result
objWs.Cells(intRow,2) = item.Vendor
objWs.Cells(intRow,3) = item.Name
objWs.Cells(intRow,1) = item.IdentifyingNumber
objWs.Cells(intRow,6) = item.UUID
Next
objWs.Cells(intRow,4) = Network.ComputerName
objWs.Cells(intRow,5) = Network.Username
set query_result = objWMI.ExecQuery("SELECT * FROM Win32_DiskDrive",,48)
driveModel = ""
driveSerial = ""
driveSize = ""
For Each item In query_result
If driveModel <> "" Then comma = ", " Else comma = "" End If
driveModel = driveModel & comma & Trim(item.Model)
driveSerial = driveSerial & comma & Trim(item.SerialNumber)
driveSize = driveSize & comma & Trim(item.Size)
Next
netMAC = ""
set query_result = objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetEnabled = True",,48)
For Each item in query_result
if netMac <> "" Then comma = ", " Else comma = "" End If
netMAC = netMAC & comma & Trim(item.MACAddress)
Next
objWs.Cells(intRow,7) = driveModel
objWs.Cells(intRow,8) = driveSerial
objWs.Cells(intRow,9) = driveSize
objWs.Cells(intRow,10) = netMAC
strQuery = "winmgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}\\" & strComputer & "\root\CIMV2\Security\MicrosoftTpm"
Set objWMI = GetObject(strQuery)
Set query_result = objWMI.InstancesOf("Win32_Tpm")
For Each item In query_result
If item.IsEnabled(A) Then objWs.Cells(intRow,11) = A End If
If item.IsActivated(B) Then objWs.Cells(intRow,12) = B End If
If item.IsOwned(C) Then objWs.Cells(intRow,13) = C End If
objWs.Cells(intRow,14) = item.SpecVersion
Next
strQuery = "winmgmts:\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption"
Set objWMI = GetObject(strQuery)
Set query_result = objWMI.InstancesOf("Win32_EncryptableVolume")
For Each item in query_result
objWs.Cells(intRow,15) = item.ProtectionStatus
Next
Set query_result = Nothing
Set objWMI = Nothing
Set Network = Nothing
Set objWs = Nothing
End Sub