A few weeks ago I found myself looking for a way to script various WDS functions using VBScript. My searches on VBscript turned up empty - nobody knew of COM objects or WMI namespaces available for use. I did a search on COM objects and found that there are indeed objects to use - and this person found it in Powershell.
The Object's name is WdsMgmt.WdsManager - and it allows you to approve and reject computers in the pending queue, list approved and rejected computers, among other functions. Here's a script that will list the approved computers - see the link above for ways to explore the object's properties and methods using Powershell.
Dim objWDS, objServer, objPending, objComputer, strMac Set objWDS = CreateObject("WdsMgmt.WdsManager", "PBORBU01") Set objServer = objWDS.GetWdsServer("localhost") Set objPending = objServer.PendingDeviceManager.GetApprovedDevices While not objPending.Eof Set objComputer=objPending.getNext() strMac = objComputer.MacAddress strMac = Mid(strMac, 21, 2) & "-" & Mid(strMac, 23, 2) & "-" & _ Mid(strMac, 25, 2) & "-" & Mid(strMac, 27, 2) & "-" & _ Mid(strMac, 29, 2) & "-" & Mid(strMac, 31, 2) Wscript.Echo "Name: " & objComputer.MachineName Wscript.Echo "MAC: " & strMac Wscript.Echo "Architecture: " & objComputer.Architecture Wscript.Echo "Last Changed: " & objComputer.LastChangeTime Wscript.Echo "Last Changed By: " & objComputer.LastChangeUser Wscript.Echo "Joined domain?: " & objComputer.JoinDomain Wscript.Echo "" Wend
No comments:
Post a Comment