Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for programatically removing user accounts from OCS 2007 R2.

I would prefer vbscript solution as this will become part of larger deprovisioning script used for removing various user related stuff across applications.

share|improve this question
add comment

1 Answer

Found the code below in the MSDN documentation here; does this serve your purposes?

    Public Function DeleteInstance(UserURI)


        ' Connect to WMI server

        Set wmiServer = CreateObject("WbemScripting.SWbemLocator").ConnectServer()

        'Do error checking here

        Query = "SELECT * FROM MSFT_SIPESUserSetting where PrimaryURI = '" & UserURI & "'"

        Set LCUserEnum = wmiServer.ExecQuery(Query)

        For each LCUser in LCUserEnum           
            Err.Clear
            LCUser.Delete_

            'Do error checking here
        Next

        DeleteInstance = true

End Function
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.