Development
Powershell: List NIC with IP, MAC and Description
by Harry on Mar.26, 2010, under Development, Microsoft
Hi Y’all, Just a quick entry for list the IP, MAC and Description fields of the NIC that are IP enabled on a system using Powershell. Might be handy for when the network team asks for MAC addresses to trace ports.
Get-WMIObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq “TRUE”} | Select-Object MACAddress,caption,description,IPAddress
Note: This command is all on one line, so beware of the word wrapping.
Update: this one is little better, it gets the network connection name as seen by Network Connections Window
Get-WmiObject win32_networkadapter | where {$_.physicaladapter -eq $true} | Select-Object macaddress,netconnectionid
Powershell tip - WMI Classes
by Harry on Sep.07, 2009, under Development, Microsoft
Here is a quick tip on how to find a WMI Class using powershell based on a keyword
get-wmiobject -list | select-string “keyword”
VB.Net
by Harry on Jun.18, 2006, under Development
This weekend has been semi productive, I managed to get some vb.net stuff going. My aim was to build a vb.net application which can create users in active directory. It was going good until I hit the a bit of a brick wall - creating exchange mailboxes. There are a lot of vbscripts out there which can be copied and customised however I want something a bit more standard and simple. I would prefer to store the code to create a mailbox in my application than to call another script which I think is another point of failure. Enter CDOEXM.DLL. This dynamic link library is installed with Exchange System Manager and is used to create mailboxes with vb.net, so they say…Google. This means you need to install system manager tools or at least register the dll. I think it is pretty lame that vb.net can’t talk to exchange and create a mailbox directly. But hey I guess I need to remember I am working with Microsoft. :)  Below is the source if somebody needs it. Ofcourse you need to modify the customizations.
Â
 Dim ObjUser, AccountName, Description
       Dim ObjNewUser As System.DirectoryServices.DirectoryEntry
       Dim ADRoot As System.DirectoryServices.DirectoryEntry
       Dim strPath As String = “LDAP://dev.local”
       Dim Item As Control
       Description = “”
       For Each Item In GroupBoxAccount.Controls
           If TypeOf Item Is RadioButton Then
               If DirectCast(Item, RadioButton).Checked = True Then Description = Item.Text
           End If
       Next
       ObjUser = (TextBoxFName.Text & “.” & TextBoxLName.Text)
       AccountName = (”cn=” & TextBoxFName.Text & ” ” & TextBoxLName.Text)
       ADRoot = New System.DirectoryServices.DirectoryEntry(”LDAP://dev.local“, “administrator”, “password”)
       ObjNewUser = ADRoot.Children.Add(AccountName, “user”)
       ObjNewUser.Properties(”sAMAccountName”).Value = ObjUser
       ObjNewUser.Properties(”Description”).Value = Description
       ObjNewUser.Properties(”givenName”).Value = TextBoxFName.Text
       ObjNewUser.Properties(”sn”).Value = TextBoxLName.Text
       ObjNewUser.CommitChanges()
       ObjNewUser.Invoke(”SetPassword”, (TextBoxPassword.Text))
       ObjNewUser.Properties(”userAccountControl”).Value = 512
       ObjNewUser.CommitChanges()