Hi all,

i need help to convert the following vbs script in kix. can anyone please help me.

' ----------------------------------------------------------------------------
'
' This file is part of the Microsoft ADS Samples.
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
'
' ----------------------------------------------------------------------------


' This sample shows creating a device. Also setting the admin MAC address (in
' class DeviceHWAddrs) and creating a device variable (class DeviceVariables).


Option Explicit
On Error Resume Next
Err.Clear


Dim objSvc ' WMI root object
Dim objDev ' to store devices class object
Dim objDevInst ' to store device instance object
Dim objDevhwaddr ' to store device hwaddr classes object
Dim objDevhwaddrInst ' to store device hwaddr instance object
Dim objDevvar ' to store device device variables class object
Dim objDevvarInst ' to store device variable instance object


' get root microsoft ads object
Set objSvc = GetObject("winmgmts:\\.\root\microsoftADS")
Call CheckForErrors("Failed: getobject root\microsoftads")



' get devices object
Set objDev = objSvc.Get("Devices")
Call CheckForErrors("Failed: get Devices object")

' spawn device instance class
Set objDevInst = objDev.SpawnInstance_()
Call CheckForErrors("Failed: spawning Device instance object")

' set device properties
objDevInst.Name = "sample1.example.com"
objDevInst.Description = "Sample device"

' create device instance
objDevInst.Put_()
Call CheckForErrors("Failed: Put_() couldn't create device")




' get device hwaddr object
Set objDevhwaddr = objSvc.Get("DeviceHWAddrs")
Call CheckForErrors("Failed: get DevicesHWAddrs object")

' create device hwaddr instance
Set objDevhwaddrInst = objDevhwaddr.SpawnInstance_()
Call CheckForErrors("Failed: spawning DeviceHwAddrs instance object")

' set device hwaddrs properties
objDevhwaddrInst.DeviceName = "sample1.example.com"
objDevhwaddrInst.type = 2
objDevhwaddrInst.hwaddr = "1234567890ab"

' create device hwaddr instance
objDevhwaddrInst.Put_()
Call CheckForErrors("Failed: Put_() couldn't create device hwaddr")





' get device variables object
Set objDevvar = objSvc.Get("DeviceVariables")
Call CheckForErrors("Failed: get DevicesVariables object")

' create device variable instance
Set objDevvarInst = objDevvar.SpawnInstance_()
Call CheckForErrors("Failed: get DevicesVariable instance object")

' set device varaible properties
objDevvarInst.DeviceName = "sample1.example.com"
objDevvarInst.Namespace = "user"
objDevvarInst.Name = "rack"
objDevvarInst.Value = "4"

' create device variable instance
objDevvarInst.Put_()
Call CheckForErrors("Failed: Put_() couldn't create device variable")


'********************************************************************
'* Sub: CheckForErrors
'*
'* Purpose: Check if there are any errors returned from the previous
'* function call.
'*
'* Input: [in] strMsg error string to display if there is an error
'*
'* Output: displays the error string to the user
'*
'********************************************************************

Sub CheckForErrors(ByVal strMsg)
Dim strErrDesc ' to store err description
Dim intErrNum ' to store err number
Dim objWbemErr ' swbemlasterror object

If Err.Number Then
intErrNum = Err.number
strErrDesc = Err.Description

If strErrDesc = "" And Err.Number Then
Set objWbemErr = CreateObject("WbemScripting.SWbemLastError")
strErrDesc = objWbemErr.Description
strErrDesc = Replace(strErrDesc, vbCRLF, " ")
End If
Wscript.Echo(strMsg & " failed: " & strErrDesc & " (0x" & CStr(Hex(intErrNum)) & ")")
WScript.Echo("---------")
Wscript.Quit(2) ' 2 is for error, 1 is warning
End If

End Sub