this code shows an approach how to generate a script for active directory measurement.
the code will do the following steps:
- flush DNS
- AD service logon
- group Policy Update
- check file on network share (optional, please contect me if you are interested)
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 |
Public Function Action() lr.start_transaction "AD_Service" Set oShell = CreateObject ("WSCript.shell") lr.output_message "---------------------------------------------" ' ----------------------------------------------------------------- ' ipconfig /flushdns START ' ----------------------------------------------------------------- iprtn = oShell.Run("ipconfig /flushdns", , true) if iprtn = 0 then lr.output_message "FLUSH_DNS Okay" lr.output_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" else lr.error_message "FLUSH_DNS Not Okay" lr.error_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" Action = lr.FAIL lr.exit 0, lr.FAIL end if ' ----------------------------------------------------------------- ' nbtstat -R START ' ----------------------------------------------------------------- iprtn = oShell.Run("nbtstat -R", , true) if iprtn = 0 then lr.output_message "NBTSTAT Okay" lr.output_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" else lr.error_message "NBTSTAT Not Okay" lr.error_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" Action = lr.FAIL lr.exit 0, lr.FAIL end if User = "<<<INSERT USERNAME HERE>>>" PW = "<<<INSERT PASSWORD HERE>>>" ' ----------------------------------------------------------------- ' AD Service START ' ----------------------------------------------------------------- lr.output_message "---------------------------------------------" set oADSI = GetObject("WinNT:") on error resume next set oIIS = oADSI.OpenDSObject("WinNT://<<<INSERT DOMAIN HERE>>>" , User, PW,0) if err.number = 0 then lr.output_message "ADService Okay" lr.output_message "VBScript Returncode:" + Cstr(err.number) lr.output_message "---------------------------------------------" else lr.error_message "ADService Not Okay" lr.error_message "VBScript Returncode:" + Cstr(err.number) lr.output_message "---------------------------------------------" Action = lr.FAIL lr.exit 0, lr.FAIL end if Set oIIS = Nothing Set oADSI = Nothing err.Clear ' ----------------------------------------------------------------- ' AD Service END ' ----------------------------------------------------------------- ' ----------------------------------------------------------------- ' gpupdate START ' ----------------------------------------------------------------- iprtn = oShell.Run("gpupdate /target:User", , true) if iprtn = 0 then lr.output_message "GPUPDATE Okay" lr.output_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" else lr.error_message "GPUPDATE Not Okay" lr.error_message "CMD Returncode:" + Cstr(iprtn) lr.output_message "---------------------------------------------" Action = lr.FAIL lr.exit 0, lr.FAIL end if Set objNetwork = Nothing err.Clear lr.end_transaction "AD_Service", lr.AUTO Set oShell = Nothing End Function |