Ying Li at myITforum.com

PowerShell & System Center

May 2010 - Posts

When you P2V a domain controller – be mindful with the “hidden” physical NIC!

We suddenly started to get the below OpsMgr alerts as on some servers we monitor event viewer.

Alert:  System Event Monitoring Rule
Source: whatever.xyz.com
Path:
Last modified by: System
Last modified time: 5/18/2010 12:09:53 PM
Alert description: Event Description: The browser service was unable to retrieve a list of servers from the browser master \\DC1 on the network \Device\NetBT_Tcpip_{E85097A4-D2FE-4E45-A53E-D47CD0F2DB1B}.
Browser master: \\DC1
Network: \Device\NetBT_Tcpip_{E85097A4-D2FE-4E45-A53E-D47CD0F2DB1B}
This event may be caused by a temporary loss of network connectivity. If this message appears again, verify that the server is still connected to the network. The return code is in the Data text box.
Alert view link: "http://MOM01:51908/default.aspx?DisplayMode=Pivot&AlertID=%7b6adff6b8-dd97-4a5b-bee4-6223ce0c593b%7d"
Notification subscription ID generating this message: {13442928-EA9E-7BF7-90C6-0F7AD57A0C94}

We followed this article and checked the File and Printer Sharing for Microsoft Networks which is enabled on DC1. I then found this article and the below session got me thinking!

“This error occurred on one of our DHCP/WINS/DNS servers (Win2k) due to replacement of hardware (NIC card). After the replacement, Windows recognized a hidden NIC with the same IP configuration. The old NIC was not visible when showing hidden devices in device manager. After removing the old card by using devcon.exe (see M269155), the message disappeared. “

That is not the exact case for us but I do remember DC1 recently upgraded to Win2K3 SP2 and was P2Ved afterword, which will have the same “hidden physical NIC” problem!

I then follow this thread removed the “hidden” NIC card, reboot DC1. The Error/Alert is GONE!

MDT 2010 – Create a Task Sequence using PowerShell to Rename Local Administrator Account

I am working on to create a Windows 7 image using MDT 2010, one of the request is to rename the local administrator account in the image. I did this in XP build which I have no problem, rename the local admin account then capture the image. The deployed image will keep my renamed local admin account. But in Windows 7 image, I just can’t do that! I rename the admin account, capture the image. But when I deploy the captured image, the local admin account reverse back to “administrator”. The indication is this is by design, may have something to do with UAC?

Here is my solution, I built my “gold” image without trying to rename local admin account. I then deploy the captured image but add a task sequence to rename local admin account. There are some ways to do this, but with my PowerShell root, I decide to accomplish using PowerShell! Michael Niehaus has a blog about how to create a task sequence using PowerShell. All we need to do is to save our PowerShell script in the %ScriptRoot% folder and then reference it in the Task Sequence like

PowerShell.exe – File “%ScriptToot%\RenameLocalAdmin.ps1

But there is a catch, as we know by default, PowerShell set the execution policy to “restricted”, in order to run our PowerShell script, we need to change the execution policy to at least “Remotesigned”

image

Here is the exact command enlightened by this thread

Powershell.exe -command "Set-ExecutionPolicy RemoteSigned; cpi z:\scripts\RenameLocalAdmin.ps1 -Destination c:\; c:\RenameLocalAdmin.ps1; ri c:\RenameLocalAdmin.ps1; Set-ExecutionPolicy Restricted"

What it does is to set the ExecutionPolicy to “RemoteSigned” ;

Copy our script from %ScriptRoot% locally to the C drive;

Run the script; and delete the script from C drive;

Last but not least, set the ExecutionPolicy  back to “Restricted”

Here is what’s in my RenameLocalAdmin.ps1

$admin=[adsi]"WinNT://./Administrator,user"
$admin.psbase.rename("whatever")

So now with this technique, running PowerShell Task Sequence in MDT 2010 is as easy as 1 – 2 – 3! :)

Windows PowerShell Cmdlets - Bing

 

Windows PowerShell Cmdlets – Bing

 

Just do a PowerShell search using Bing – it’s very cool!