Tuesday, September 4, 2012

Enabling/Disabling NIC via Command line

I recently found that I need for my system to be on multiple VLANs at different times.  Now, my NIC supports this and it is fairly easy to do in Windows 7, but I wanted to make it easier.  To accomplish this I wrote a little batch file that simply enables or disables the network interface card via wmic.

The NIC is configured with the following commands:

  • To determine the index value (##)
    • wmic nic get name, index
  • To Enable
    • wmic path win32_networkadapter where index=## call enable
  • To Disable
    • wmic path win32_networkadapter where index=## call disable

I then have the batch file with a choice statement that allows me to select the option I want.

I found the original information on how to accomplish this task here.

Friday, August 3, 2012

Ghost Network Interface Cards

Recently, I imported a bunch of virtual machines.  After the import was complete, only one nic showed up under network adapters but when making any changes to the static IP's a warning was shown stating duplicate information.  After doing some digging, I found that there were actually 2 NICs in the system, but only one was being display.   I tried multiple ways to get the second card removed, but had no success until I came across a few posts mentioning devcon.

Using devcon you can perform the following command line options to remove the ghosted nic:

  • Run this command to list all the network hardware
    •  devcon findall =net  
  • This will output a bunch of information in the format PCI\VEN_xxxxx : Adapter Name
  • Copy the string before the colon.
  • Run the devcon command to remove the nic
    • devcon -r remove "@PCI\Ven_xxxxxx"


The biggest issue I ran into was getting devcon for the correct architecture.  The inital post I read linked to Microsoft for the x86 and ia64, but my systems were running x64.  So, I managed to find the tool on a Windows Server installation media for x64.  But I have also found it online as part of the Windows Driver Kit with instruction on how to extract it here How to Obtain the Current Version of Device Console Utility (DevCon.exe)

Thursday, March 8, 2012

DHCP Information

I came across a recent little command that helped me out a lot.  I was trying to determine all of the information of a DHCP server that had multiple reservations.  Now, I could use the management console and just export the IP and reservation name.  But this did not give me the MAC addresses or any additional information.  I also wanted to just have the basic info of the DHCP scope.  So, after some searching I found a fairly easy way to do it.  I ran the command:

netsh dhcp server dump >> C:\DHCP_Info.txt

This created a file DHCP_Info.txt in the root drive that contained all the information i needed.  I just had to parse the section that listed reservations and import it into a table.

Wednesday, February 15, 2012

Windows 7 Activation Issues

So, I have been working at my new job for a few weeks now and one of the things I have been doing a little is upgrading Windows Installations offline.  I have used Autopatcher and the WSUS Offiline.  Both have been great when we can not connect the system to the network.

However, I have been running into a problem. When Activating windows, the activation fails.  You get an error message in the typical cryptic Microsoft style of error code 0x8007007b

Basically, you can not activate windows and you only have your grace period to use the system. This is a result of us using volume licensing, the solution that works best for me is as follows.
  • Run the following commands 
    • slmgr.vbs /ipk <product key from MSDN (MAK)> (This installs the product key) 
    • slmgr.vbs /ato (This activates windows) 
    • Optional - slmgr.vbs /dlv (Shows current activation status)

Monday, February 6, 2012

Google Takeout

I have been looking for a while for a good way to export all my Google data, since my previous company was using Google Apps for email, and while this doesn't get everything, it is still pretty inclusive.

Check it out at Google Takeout


Tuesday, November 22, 2011

Windows Profile Location

This is another one of my favorite techniques when setting up a new system.  What I generally like to do is take the existing hard drive and re-partition it into 2 drives.  I do this using the excellent freeware GParted  I generally do an even split, but it doesn't have to be, just giving the second partition as much space as possible to store user data.  I then name the second partition something like Storage.  For sake of instructions, lets just say it is assigned the drive letter D

One that is done, before logging in as the systems user, I edit the registry as follows:
(This is for Win 7 system, but an XP system is very similar)


  • On the D:\ create a new folder Users
  • Using regedit, navigate to:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  • Edit Profiles Directory from %SystemDrive%\Users to D:\Users
  • Log Out of the system
  • Login as a new user
This allows the new user to have their information stored on the 2nd partition so that when you want to reinstall everything you can without worrying about losing all your data.

From that same registry key, you can also edit the profile locations of the existing users of the system such that if you already logged in as a user, you can easily change it from the default location.  You will just have to look at the subkeys of ProfileList that display GUIDs instead of names and find the one with the appropriate path.


Tuesday, November 1, 2011

Active Directory Change Password Issues

We had a new employee start and I have been asking her to change her password.  She has told me that she has been unable to do so as every time she tries, she gets an error about not meeting requirements.
She is using a Dell Latitude running Windows 7 32-Bit.
I tried to do the same thing on multiple systems with my account and getting the same error.  When I tried form an XP system, the error message was a little clearer.  I searched all over for an answer and finally foudn the solution.
It seems that a few changes were made to the Default Domain group policy to enforce password age.  Well, the only issue is that the minimum password age was not set, and defaulted to 30 days.  Once I reset this to 0 as a test, I was able to have her successfully set her password.
Guess it goes to show, make sure you know what your GPO says.  :-)