Delen via


Sample Code (VBScript) - Retrieve MIIS WMI Password History

This is a sample WMI script to retrieve password change history for a specific account through MIIS. You just need to run it on MIIS server with MA name, domain name and account name as parameters.

Option Explicit

On Error Resume Next

Dim Service
Dim CsObjects
Dim CsObject
Dim Arguments
Dim domainName
Dim ma
Dim account
Dim MVGuid
Dim password
Dim oldPassword
Dim r

Set Arguments = WScript.Arguments.Named

domainName = Arguments.Item("D")
account = Arguments.Item("A")
ma = Arguments.Item("M")

Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer")
Set CsObjects = Service.ExecQuery("Select * from MIIS_CSObject where domain='" + domainName + "' and account='" + account + "'")

For each CsObject in CsObjects
   MVGuid = CsObject.MVGuid
Next

Set CsObjects = Service.ExecQuery("Select * from MIIS_CSObject where mvguid='" + MVGuid  + "'")

For each CsObject in CsObjects
   if LCase(CsObject.MAName) = LCase(ma) then
 wscript.echo "Retrieving MIIS WMI Password History ..."
 wscript.Echo CsObject.PasswordChangeHistory
   end if
Next

Sub ErrorHandler (ErrorMessage)
  WScript.Echo ErrorMessage
  WScript.Quit(1)
End Sub