Connect to a remote server with different user/password using .NET/WMI

I’ve seen various posts in the newsgroups how to use .NET to connect to a remote server to collect WMI information. 


Dim options As New ConnectionOptions()
options.Username = “Domain\UserId”
options.Password = “password”

Dim scope As New ManagementScope(“\\ServerName\root\cimv2”, options)
Dim strSVCquery As String = ConfigurationSettings.AppSettings(“NICquery”)

Dim objNICQuery As New WqlObjectQuery(strSVCquery)
Dim objNICsearcher As New ManagementObjectSearcher(scope, objNICQuery)

Dim envVar As New ManagementObject()

Dim objNICItem As PropertyData
Dim strNICColName As String

scope.Connect()
For Each envVar In objNICsearcher.Get
        For Each objNICItem In envVar.Properties
            strNICColName = objNICItem.Name
            If Not IsArray(objNICItem.Value) Then
                Console.WriteLine(“Item is NOT an array — ” & strNICColName)
            Else
                Console.WriteLine(“Item is an array — ” & strNICColName)
            End If
        Next
Next

AWebMonitorService

A Web Monitor Server


This is my own project that I recently did to learn how to write Windows Services using .NET.  This is drop-dead simple using the framework.  Current .25 release # This project is called AWEBMONITORSERVICE. This is written in C# that is designed currently to monitor a single website. This service will email, write to the Event Log or write to a SQL database.

Download source!

Windows 2003 Active Directory anyone!

I spent Sunday afternoon (yes it was 10 degrees where i’m at), reading an ebook from netpro.   This is a six chapter series on Active Directory Troubleshooting.  Good read for those who are doing server admin with Active Directory.  This ebook targets windows 2000 active directory but apply’s to Windows 2003 as well.  My favorite chapter was #4, this chapter covers performance counters to use to help tune and monitor AD along with server counters.  http://www.netpro.com/ebook/index.cfm  is the homepage  These are free however you have to register.    I’d highly recommend anyone to download this good resource. 

Secondly, download the Windows 2003 server resource kit.  http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en  The resource kit is rich in utilities, one of my favorite is called getmac, this gets the MAC address of remote machines, you can even pass credentials.   http://www.microsoft.com/windowsserver2003/techinfo/reskit/resourcekit.mspx  has more info also (IIS 6 resource kit!).


Lastly this is my favorite geek toy of the month!  Microsoft released Services for Unix 3.5 recently w/o an license restrictions or cost.  Download today at http://www.microsoft.com/windows/sfu/downloads/default.asp