<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Obscurum per Obscurius : Script</title><link>http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx</link><description>Tags: Script</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Who Is Logged In?</title><link>http://blogs.msdn.com/muaddib/archive/2009/08/09/who-is-logged-in.aspx</link><pubDate>Mon, 10 Aug 2009 01:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9862816</guid><dc:creator>MuadDib</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/9862816.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=9862816</wfw:commentRss><description>A few months back one of my customers was trying use RDP to connect to a large number of desktop computers to manually install some security updates. If the computer was being used the admin had to wait until the person using the computer logged out and...(&lt;a href="http://blogs.msdn.com/muaddib/archive/2009/08/09/who-is-logged-in.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9862816" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Testing Domain Controller Connectivity Using PORTQRY</title><link>http://blogs.msdn.com/muaddib/archive/2009/03/29/testing-domain-controller-connectivity-using-portqry.aspx</link><pubDate>Mon, 30 Mar 2009 03:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9517728</guid><dc:creator>MuadDib</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/9517728.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=9517728</wfw:commentRss><description>&lt;P&gt;One common problem I see with Active Directory implementations is an Active Directory topology that is not fully routable.&amp;nbsp; In a fully routable environment every domain controller (DC) can communicate with every other DC.&amp;nbsp; While&amp;nbsp;most customers "think" they have a fully routable environment in reality they do not.&amp;nbsp; In some cases there are multiple firewalls between the DCs that are blocking ports or DCs connected across VPN links that do not have the proper ports open.&amp;nbsp; For more information on how Active Directory replication works read&amp;nbsp;the&amp;nbsp;articles in the RESOURCES section below.&lt;/P&gt;
&lt;P&gt;Here are the ports required by Active Directory as described&amp;nbsp;in the "Service Overview" link below.&amp;nbsp; The basic ports are TCP: &lt;/P&gt;
&lt;P&gt;88 (Kerberos)&lt;BR&gt;135 (RPC)&lt;BR&gt;389 (LDAP)&lt;BR&gt;445 (CIFS)&lt;BR&gt;3268&amp;nbsp;(Global Catalog)&lt;/P&gt;
&lt;P&gt;There are additional ports and protocols but these are enough to get started testint the basics.&lt;/P&gt;
&lt;P&gt;The PORTQRY utility can be found in the Windows Server 2003 Support Tools and the newest version can be found in the links that follow.&amp;nbsp; PORTQRY can be used to test connectivity on a port or range of ports from one server to another.&amp;nbsp; For example to test TCP port 389 from the current computer to a server named VDC02 you would type the following command:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;PORTQRY - n VDC02 -e 389 -p TCP&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The query will return a great deal of information when you query 389 but you should see a line similar to the following if port 389 is reachable and able to respond:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;TCP port 389 (ldap service): LISTENING&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In order to speed up the process of testing you can use a batch file with a FOR loop in it to read server names from a text file and perform several ports test against a server.&amp;nbsp; The sample script shown below will perform some basic testing but you might need to perform more detailed analysis if you are having problems (note somelines may be wrapped due to blog formatting).&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;::::::::::::::::::::::::::::&amp;nbsp;BEGIN SCRIPT :::::::::::::::::::::::::&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&amp;nbsp;@ECHO OFF&lt;BR&gt;:: NAME: DCPortTest.CMD v1.0&lt;BR&gt;:: DATE: 03/29/2009&lt;BR&gt;:: PURPOSE:&amp;nbsp; Test connectivity from one DC to one or more remote DCs&lt;BR&gt;:: using PORTQRY utility. &lt;BR&gt;:: The SERVERS.TXT contains a list of servers (one server per line)&lt;BR&gt;:: to check connectivity to.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT size=1&gt;ECHO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE: %DATE% &amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TIME: %TIME% &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USER: %USERNAME% &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO COMPUTER: %COMPUTERNAME% &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;FOR /F "tokens=1" %%i in (servers.txt) DO (&lt;BR&gt;&amp;nbsp;ECHO ::::::::::::::::::::::&amp;nbsp; %%i&amp;nbsp; :::::::::::::::::::::::::: &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;ECHO Testing %%i&lt;BR&gt;&amp;nbsp;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;PORTQRY -n %%i -e 88 -p TCP | findstr /i "88"&amp;nbsp; &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;PORTQRY -n %%i -e 445 -p TCP | findstr /i "445" &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;PORTQRY -n %%i -e 389 -p TCP | findstr /i "389" &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;PORTQRY -n %%i -e 3268 -p TCP | findstr /i "3268"&amp;nbsp; &amp;gt;&amp;gt; DC_PORTQRY.TXT &lt;BR&gt;&amp;nbsp;PORTQRY -n %%i -e 135 -p TCP | findstr /i "135" &amp;gt;&amp;gt; DC_PORTQRY.TXT&lt;BR&gt;&amp;nbsp;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT &amp;nbsp;&lt;BR&gt;&amp;nbsp;ECHO. &amp;gt;&amp;gt; DC_PORTQRY.TXT &amp;nbsp;&lt;BR&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;::::::::::::::::::::::::&amp;nbsp;END SCRIPT :::::::::::::::::::::::::&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;RESOURCES&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How Active Directory Replication Topology Works&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://technet2.microsoft.com/WindowsServer/en/Library/c238f32b-4400-4a0c-b4fb-7b0febecfc731033.mspx" mce_href="http://technet2.microsoft.com/WindowsServer/en/Library/c238f32b-4400-4a0c-b4fb-7b0febecfc731033.mspx"&gt;http://technet2.microsoft.com/WindowsServer/en/Library/c238f32b-4400-4a0c-b4fb-7b0febecfc731033.mspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Service overview and network port requirements for the Windows Server system&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/kb/832017" mce_href="http://support.microsoft.com/kb/832017"&gt;http://support.microsoft.com/kb/832017&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;New features and functionality in PortQry version 2.0&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/kb/832919" mce_href="http://support.microsoft.com/kb/832919"&gt;http://support.microsoft.com/kb/832919&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Download PortQry Command Line Port Scanner Version 2.0&lt;/STRONG&gt;&lt;BR&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&amp;amp;displaylang=en&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9517728" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Active+Directory/default.aspx">Active Directory</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Finding Scheduled Tasks Configured with Disabled Accounts</title><link>http://blogs.msdn.com/muaddib/archive/2009/01/13/finding-scheduled-tasks-configured-with-disabled-accounts.aspx</link><pubDate>Tue, 13 Jan 2009 19:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9315980</guid><dc:creator>MuadDib</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/9315980.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=9315980</wfw:commentRss><description>&lt;P&gt;One of my customers has undergone a great deal of turnover in the past few weeks on the System Administration team.&amp;nbsp; We discovered that a number of Scheduled Tasks configured on the servers were configured with the accounts of admnistrators (instead of service accounts!).&amp;nbsp; The accounts were disabled when the admins left the organization and&amp;nbsp;the Scheduled Tasks stopped working.&amp;nbsp; We needed to find all the Scheduled Tasks configured with admin accounts instead of service accounts on the servers.&lt;/P&gt;
&lt;P&gt;The simpe batch file below uses the SCHTASKS utility to dump the configuration information from each server listed in a SERVERS.TXT file and dump the output to a file named SCHED_TASKS_CONFIG.TXT.&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;&amp;lt;------------------------------BEGIN BATCH FILE-------------------------&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;:: NAME: SCHED_TASK_ACCT.CMD v1.0&lt;BR&gt;:: DATE: 1/13/2009&lt;BR&gt;:: PURPOSE:&amp;nbsp; TO dump the configuration of scheduled tasks on a server to a text file&lt;BR&gt;::&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; so tasks configured with disabled accounts can be located.&lt;/P&gt;
&lt;P&gt;ECHO %DATE% &amp;gt; SCHED_TASKS_CONFIG.TXT&lt;BR&gt;ECHO %TIME% &amp;gt;&amp;gt; SCHED_TASKS_CONFIG.TXT&lt;BR&gt;ECHO %USERNAME% &amp;gt;&amp;gt; SCHED_TASKS_CONFIG.TXT&lt;BR&gt;ECHO. &amp;gt;&amp;gt; SCHED_TASKS_CONFIG.TXT&lt;BR&gt;FOR /F "tokens=1" %%i in (servers.txt) DO schtasks /query /s %%i /v /fo list &amp;gt;&amp;gt; SCHED_TASKS_CONFIG.TXT&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;&amp;lt;------------------------------END BATCH FILE-------------------------&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9315980" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Using a Logon Script to Install the SMS Advanced Client</title><link>http://blogs.msdn.com/muaddib/archive/2008/10/19/using-a-logon-script-to-install-the-sms-advanced-client.aspx</link><pubDate>Sun, 19 Oct 2008 16:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9006252</guid><dc:creator>MuadDib</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/9006252.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=9006252</wfw:commentRss><description>&lt;P&gt;One of my customers has an extensive lab environment with multiple forests, domains and workgroup computers.&amp;nbsp; SMS 2003 was deployed to help manage the configuration of all these different systems.&amp;nbsp; Between the locked down&amp;nbsp;security settings (no C$, ADMIN$ shares!)&amp;nbsp;and the number&amp;nbsp;separate&amp;nbsp;forest/domains/workgroups involved the ability to "push" the advanced client&amp;nbsp;to desktops is no longer an option.&amp;nbsp; After meeting with the client last week we decided to configure a logon script to install the SMS client.&amp;nbsp; The script and associated files (CCMSETUP.EXE, CLIENT.MSI, SMSCLIENT.VBS) were placed in a folder named SMS in the NETLOGON share of the Domain Controllers.&amp;nbsp; We then configured the LOGON SCRIPT properties of the Domain Administrator account to run the SMSSTARTUP.VBS script shown below to install the client.&lt;/P&gt;
&lt;P&gt;Now for a quick run through of the code.&amp;nbsp; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Declare our variables and create the objects we will be working with.&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;Determine the path to the NETLOGON \SMS folder we are using.&lt;/LI&gt;
&lt;LI&gt;Check to see if the SMS client is installed (Set oSMSClient ... If Err.Number....)&lt;/LI&gt;
&lt;LI&gt;Display a timed popup message with a Cancel button&lt;/LI&gt;
&lt;LI&gt;Copy install files to local computer.&lt;/LI&gt;
&lt;LI&gt;Run installation script (SMSCLIENT.VBS)&lt;/LI&gt;
&lt;LI&gt;Set commands in the RunOnce registry key to delete the SMSCLIENTINSTALL folder the next time someone logs in.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;SMSSTARTUP.VBS&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;'**********************************************&lt;BR&gt;'&amp;nbsp; SCRIPT: SMSStartup.VBS&lt;BR&gt;'&amp;nbsp; AUTHOR: &lt;BR&gt;'&amp;nbsp; DATE:&amp;nbsp;&amp;nbsp; 10/16/2008&lt;BR&gt;' VERSION: 2.0&lt;BR&gt;' PURPOSE: Check for thr presence of the SMS client,&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if not installed, copy files from the &lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; network to c:\smsclientinstall and install&lt;BR&gt;'&amp;nbsp;USAGE:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSStartup.vbs&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;'REVISION:&amp;nbsp;10/17/2008 added check&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;to make sure files and folders exist &lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; before moving to next step in script&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;'**********************************************&lt;BR&gt;OPTION EXPLICIT&lt;BR&gt;On Error Resume Next&lt;/P&gt;
&lt;P&gt;Dim oSMSClient, intButton,objWshShell,sFolder, objFSO, sCurrentPath&lt;BR&gt;Dim oExec&lt;/P&gt;
&lt;P&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;BR&gt;Set objWshShell = WScript.CreateObject("WScript.Shell")&lt;BR&gt;Set oSMSClient = CreateObject ("Microsoft.SMS.Client")&lt;/P&gt;
&lt;P&gt;'Folder to copy SMS install files to &lt;BR&gt;sFolder = "C:\SMSCLIENTINSTALL"&lt;/P&gt;
&lt;P&gt;WScript.Sleep 15000&lt;/P&gt;
&lt;P&gt;'Build path to SMS files&lt;BR&gt;sCurrentPath = objWshShell.ExpandEnvironmentStrings("%LOGONSERVER%")&lt;BR&gt;sCurrentPath = sCurrentPath &amp;amp; "\NETLOGON\SMS"&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Err.Number &amp;lt;&amp;gt; 0 Then 'change to zero when testing complete&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Clear error buffer &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; err.clear&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; objWshShell.LogEvent 2, "SMS Client is not installed, installing now."&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; intButton=objWshShell.Popup("Installaing SMS Client software on this computer in the background",5,"SMS Client Software Installation",1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'wscript.echo intbutton&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If intButton = 2 Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objWshShell.LogEvent 1, "SMS Client installation was cancelled by the user"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.quit&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;'copy files to local computer and begin client installation&lt;BR&gt;&amp;nbsp;Do While objFSO.FolderExists(sFolder) &amp;lt;&amp;gt; TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;CreateFolder sFolder&lt;BR&gt;&amp;nbsp;&amp;nbsp;WScript.Sleep 10000&lt;BR&gt;&amp;nbsp;Loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;'copy files&lt;BR&gt;&amp;nbsp;'Check for files before continuing to next file&lt;BR&gt;&amp;nbsp;Do While objFSO.FileExists(sFolder &amp;amp; "\SMSCLIENT.VBS") &amp;lt;&amp;gt; TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;objFSO.CopyFile sCurrentPath &amp;amp; "\SMSCLIENT.VBS", sFolder &amp;amp; "\", TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;wscript.sleep 2000&lt;BR&gt;&amp;nbsp;Loop&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;Do While objFSO.FileExists(sFolder &amp;amp; "\Client.msi") &amp;lt;&amp;gt; TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;objFSO.CopyFile sCurrentPath &amp;amp; "\client.msi", sFolder &amp;amp; "\", TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;wscript.sleep 2000&lt;BR&gt;&amp;nbsp;Loop&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;Do While objFSO.FileExists(sFolder &amp;amp; "\ccmsetup.exe") &amp;lt;&amp;gt; TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;objFSO.CopyFile sCurrentPath &amp;amp; "\ccmsetup.exe", sFolder &amp;amp; "\", TRUE&lt;BR&gt;&amp;nbsp;&amp;nbsp;wscript.sleep 2000&lt;BR&gt;&amp;nbsp;Loop&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'now run sms client install&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oExec = objWshShell.Exec("wscript.exe " &amp;amp; sFolder &amp;amp; "\SMSCLIENT.VBS")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do While oExec.Status = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.Sleep 1000&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;'delete the folder by adding command to the Runonce key&lt;BR&gt;&amp;nbsp;'CMD.exe /c "RD /s /q c:\SMSCLIENTINSTALL"&lt;BR&gt;&amp;nbsp;objWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\SMS", "CMD.EXE /c " &amp;amp; CHR(34) &amp;amp; "RD /s /q C:\SMSCLIENTINSTALL" &amp;amp; CHR(34), "REG_SZ"&lt;/P&gt;
&lt;P mce_keep="true"&gt;Else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Computer has client, quit&lt;BR&gt;&amp;nbsp;wscript.quit&lt;BR&gt;End If&lt;/P&gt;
&lt;P&gt;Function CreateFolder(folder)&lt;BR&gt;&amp;nbsp;&amp;nbsp; Dim ofso, f&lt;BR&gt;&amp;nbsp;&amp;nbsp; Set ofso = CreateObject("Scripting.FileSystemObject")&lt;BR&gt;&amp;nbsp;&amp;nbsp; Set f = ofso.CreateFolder(folder)&lt;BR&gt;&amp;nbsp;&amp;nbsp; CreateFolder = f.Path&lt;BR&gt;End Function&lt;/P&gt;
&lt;P&gt;Sub DeleteAFolder(filespec)&lt;BR&gt;&amp;nbsp;&amp;nbsp; Dim ofso&lt;BR&gt;&amp;nbsp;&amp;nbsp; Set ofso = CreateObject("Scripting.FileSystemObject")&lt;BR&gt;&amp;nbsp;&amp;nbsp; ofso.DeleteFolder filespec,TRUE&lt;BR&gt;End Sub&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9006252" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/SMS/default.aspx">SMS</category></item><item><title>Configuring SMS to Work on Workgroup Computers and Computers in Other Domains (LMHOSTS)</title><link>http://blogs.msdn.com/muaddib/archive/2008/10/19/configuring-sms-to-work-on-workgroup-computers-and-computers-in-other-domains-lmhosts.aspx</link><pubDate>Sun, 19 Oct 2008 16:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9006247</guid><dc:creator>MuadDib</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/9006247.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=9006247</wfw:commentRss><description>&lt;P&gt;As described in the previous post the&amp;nbsp;lab environment includes&amp;nbsp;multiple forests, domains and workgroup computers.&amp;nbsp;&amp;nbsp;One of the nice things about SMS 2003 is the fact that once the SMS Client has been installed on a system, you "own" that system and can manage it from that day forward.&amp;nbsp; In the previous post, we discussed how to use a logon script to install the SMS Advanced Client.&amp;nbsp; In this post we will discuss how to configure computers that are not located within the same domain as the SMS server to be able to find the SMS Management Point (MP) and Server Locator Point (SLP).&lt;/P&gt;
&lt;P&gt;All&amp;nbsp;Windows operating systems since Windows 2000 rely on DNS for name resolution.&amp;nbsp; A&amp;nbsp;clients still have WINS installed to support some legacy applications but&amp;nbsp;most do not.&amp;nbsp; An LMHOSTS file is similar to a HOSTS file.&amp;nbsp; A HOST files is used to map DNS hosts names to IP addresses.&amp;nbsp; An LMHOSTS file is used to map NetBIOS names to IP addresses.&amp;nbsp;&amp;nbsp; NetBIOS names differ from DNS names because you can have different types of NetBIOS names (e,g, domain, workstation service etc.).&amp;nbsp; The LMHOSTS files is placed in the same folder as the HOSTS file (%WINDIR%\System32\Drivers\Etc).&lt;/P&gt;
&lt;P&gt;An example of the LMHOSTS file is shown below.&amp;nbsp; Copy the code below into Notepad and save the file as LMHOSTS (no extension) to the "%WINDIR%\System32\Drivers\Etc" folder.&amp;nbsp; Customize the entries to match your environment.&amp;nbsp; When you see the pound (#) sign in an LMHOSTS file it is usually followed by a comment unless it is followed by one of the special directives such as PRE&amp;lt; DOM, INCLUDE etc.&amp;nbsp; The PRE directive loads the entires into the NetBIOS name cache on startup.&amp;nbsp; The DOM directive is used to indicated a domain name.&amp;nbsp; The INCLUDE directive is used to include another LMHOSTS file.&lt;/P&gt;
&lt;P&gt;In the sample file below the first three lines are comments.&amp;nbsp; The fourth line pre-loads the domain name where the SMS servers is located and provides the IP address of a DC in that domain.&amp;nbsp; The next line provides the name and IP address of the SMS server (SMSSERVER1).&amp;nbsp; The next line provides the name of the SMS Server Locator Point (SMS_SLP) and the line that follows defines the Management Point (MP_C01).&amp;nbsp; Notice the entries for the&amp;nbsp;SLP/MP look very different from the others.&amp;nbsp; The "\01xa"&amp;nbsp;is a NetBIOS suffix and there must be exactly 15 characters between the the first quote and the backslash.&amp;nbsp; For the SMS_SLP line on change the IP address to the IP of the computer hosting the SMS SLP role.&amp;nbsp; For the MP, change the IP and change the SMS site code in the file from C01 to the site code of your SMS site.&lt;/P&gt;
&lt;P&gt;&amp;lt;------------------------------ BEGIN LMHOSTS -----------------------------------&amp;gt;&lt;/P&gt;
&lt;P&gt;# LAB LMHOSTS File&lt;BR&gt;#REVISION: 2&lt;BR&gt;#DATE: 10/17/2008&lt;BR&gt;192.168.101.143&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DC01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #PRE #DOM:LABDOMAIN1&amp;nbsp; # Lab Domain&amp;nbsp;DC&lt;BR&gt;192.168.101.141&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSSVR1 #PRE&lt;BR&gt;192.168.101.141&amp;nbsp;&amp;nbsp;&amp;nbsp;"SMS_SLP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \0x1A" #PRE&lt;BR&gt;192.168.101.141&amp;nbsp;&amp;nbsp; "MP_C01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \0x1A" #PRE&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;------------------------------&amp;nbsp;&amp;nbsp;&amp;nbsp; END LMHOSTS -----------------------------------&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;When you start using LMHOST files you quickly realize that trying to manage the content of these files on multiple computers because a big pain real fast.&amp;nbsp; If you need to make a change, you need to update every file with the&amp;nbsp;change.&amp;nbsp; Fortunately the #INCLUDE&amp;nbsp;directive discussed earlier enables you to use a centralized LMHOSTS file.&amp;nbsp; In our lab environment we created a share on the SMS server named "SMSLMHOST" and placed the first LMHOSTS file shown above there.&amp;nbsp; The LMHOSTS file shown below was placed on the computers that needed a LMHOSTS.&amp;nbsp; There are two entries shown.&amp;nbsp; The first one provides the name/IP of the SMS server and the second directs the client to read the master LMHOSTS file stored on the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;lt;------------------------------&amp;nbsp;&amp;nbsp;&amp;nbsp;BEGIN LMHOSTS -----------------------------------&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;192.168.101.141&amp;nbsp;SMS1&amp;nbsp;#PRE&lt;BR&gt;#INCLUDE \\SMSSVR1\SMSLMHOSTS\lmhosts&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;------------------------------&amp;nbsp;&amp;nbsp;&amp;nbsp; END LMHOSTS -----------------------------------&amp;gt;&lt;/P&gt;
&lt;P&gt;REFERENCE&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NetBIOS Suffixes (16th Character of the NetBIOS Name)&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/default.aspx/kb/163409/"&gt;http://support.microsoft.com/default.aspx/kb/163409/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HOWTO: Assign SMS Advanced Client to the Isolated Secondary Site &lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/kb/555853"&gt;http://support.microsoft.com/kb/555853&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;LMHOSTS File Information and Predefined Keywords&lt;/STRONG&gt;&lt;BR&gt;&lt;A href="http://support.microsoft.com/kb/102725"&gt;http://support.microsoft.com/kb/102725&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Domain Browsing with TCP/IP and LMHOSTS Files&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/kb/150800"&gt;http://support.microsoft.com/kb/150800&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Chapter 10 - Using LMHOSTS Files&lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://www.microsoft.com/resources/documentation/windowsnt/4/server/reskit/en-us/net/sur_lmh.mspx?mfr=true"&gt;http://www.microsoft.com/resources/documentation/windowsnt/4/server/reskit/en-us/net/sur_lmh.mspx?mfr=true&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9006247" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Reference/default.aspx">Reference</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/SMS/default.aspx">SMS</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/NetBIOS/default.aspx">NetBIOS</category></item><item><title>Who's in the Local Administrators Group?</title><link>http://blogs.msdn.com/muaddib/archive/2008/10/12/who-s-in-the-local-administrators-group.aspx</link><pubDate>Sun, 12 Oct 2008 16:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8996652</guid><dc:creator>MuadDib</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/8996652.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=8996652</wfw:commentRss><description>&lt;P&gt;I was organizing files this weekend and ran across a script I created for a customer recently.&amp;nbsp;&amp;nbsp; They we trying to determine the membership of the local Administrators group on each computer on their network.&amp;nbsp; The had determined that non-admin users were being added to the local Administrator group and needed to know how widespread the problem was.&amp;nbsp; Once they determine that I recommended they use Group Policy, Restricted Groups to fix the problem.&lt;/P&gt;
&lt;P&gt;The VBScript below follows my standard script format that starts with an input file (INPUT.TXT) with a list of computers and automatically creates a tab-separated (for analysis in Excel)&amp;nbsp;output file based on the name of the input file and appends RESULTS.TXT to the name.&amp;nbsp; Once we&amp;nbsp;open&amp;nbsp;the input for to read, &amp;nbsp;and the output file for writing we start the loop.&amp;nbsp; The real work happens in the DO WHILE loop.&amp;nbsp; First thing we do is run a Function named Get ComputerStatus.&amp;nbsp; Since we are connecting to a remote computer, I use this function to determine if a computer is online by pinging it.&amp;nbsp; If it is online we continue, if not we write "Computer Could Not Be Contacted" to the log and get the next computer in the list.&amp;nbsp; The EnumGroup function is used to get the membership of the local Administrators group and write it to the log file.&amp;nbsp; Once we finish the files are closed and the log file is opened in notepad.&lt;/P&gt;
&lt;P&gt;To use this script, copy the contents to notepad and save the file with a VBS extension.&amp;nbsp; Create an input file with computer nameon each line.&amp;nbsp; You can run the script by double clicking it but I prefer to run it from a command prompt using cscript so that I only have a single command prompt instead of a command prompt for every "ping".&amp;nbsp; If anyone uses this script and finds it useful leave me a comment and/or a rating.&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;LocalAdminGroupMembership.vbs&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;'**********************************************&lt;BR&gt;'&amp;nbsp; SCRIPT: LocalAdminGroupMembership.vbs&lt;BR&gt;'&amp;nbsp; AUTHOR: Muaddib :-)&lt;BR&gt;'&amp;nbsp;&amp;nbsp;DATE: 08/21/08&lt;BR&gt;' VERSION: 1.0&lt;BR&gt;' PURPOSE: Used to Query remote computers and enumerate memebers of &lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local admin group&lt;BR&gt;'&amp;nbsp;&amp;nbsp; USAGE: 1. List computers to be queried in input.txt (other text file)&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. LocalAdminGroupMembership.vbs&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. Output file, results.txt will show status&lt;BR&gt;'Revision: &lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;'&lt;BR&gt;'**********************************************&lt;/P&gt;
&lt;P&gt;Option Explicit&lt;/P&gt;
&lt;P&gt;'ON ERROR RESUME NEXT 'Do Not Uncomment until script is ready for production&lt;/P&gt;
&lt;P&gt;Dim oWshShell, oFSO, oFileName1, oFilename2, objWMIService, colItems, sProtocol, sSearch, sNWStatus, sDate, iErrNumber&lt;BR&gt;Dim objItem, strComputer, oExec, strPingStdOut, sStatus, bComputerOnline, aComputers, Computer, sOutPutFile, sInPutFile, sComputerStatus&lt;BR&gt;Dim arrFileNAme, sOutPutFileName,objGroup, strOffset&lt;/P&gt;
&lt;P&gt;CONST ForReading = 1&lt;BR&gt;CONST ForWriting = 2&lt;BR&gt;CONST ForAppending = 8&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;'Prompt for name of input file&lt;BR&gt;sInPutFile = INPUTBOX("Enter name of input file.&amp;nbsp; Input file must exist in the script folder.", "Enter Input File Name","input.txt" )&lt;BR&gt;IF sInputFile = "" THEN&lt;BR&gt;&amp;nbsp;&amp;nbsp; wscript.echo "Operation was cancelled"&lt;BR&gt;&amp;nbsp;&amp;nbsp; wscript.quit&lt;BR&gt;END IF&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;'Trim extension from sInputFile1&amp;nbsp;&amp;nbsp; &lt;BR&gt;arrFileNAme = Split(sInPutFile, ".")&lt;BR&gt;sOutPutFileName = UCASE(arrFIleNAme(0))&lt;BR&gt;'Prompt for name of output file&lt;BR&gt;sOutPutFile = INPUTBOX("Enter name of output file.&amp;nbsp; Output file will be placed in script folder.", "Enter Output File Name",sOutPutFileName &amp;amp; "_RESULTS.TXT" )&lt;BR&gt;IF sOutPutFile = "" THEN&lt;BR&gt;&amp;nbsp;&amp;nbsp; wscript.echo "Operation was cancelled"&lt;BR&gt;&amp;nbsp;&amp;nbsp; wscript.quit&lt;BR&gt;END IF&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Set oWshShell = Wscript.CreateObject("Wscript.Shell")&lt;BR&gt;Set oFSO = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;
&lt;P&gt;'Open input file and read&lt;BR&gt;Set oFilename1 = oFSO.OpenTextFile(".\" &amp;amp; sInPutFile, ForReading, False)&lt;BR&gt;iErrNumber = err.number&lt;BR&gt;&amp;nbsp; 'Check for missing file&lt;BR&gt;&amp;nbsp; IF iErrNumber = 53 THEN&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wscript.echo "Error - " &amp;amp; sInPutFile &amp;amp; " file was not found."&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wscript.quit&lt;BR&gt;&amp;nbsp; END IF&lt;/P&gt;
&lt;P&gt;Set oFilename2 = oFSO.OpenTextFile(".\" &amp;amp; sOutPutFile, ForWriting, True)&lt;/P&gt;
&lt;P&gt;' OPTIONAL LOG HEADER&lt;BR&gt;'Get date and write it to log&lt;BR&gt;'sDate = Now()&lt;BR&gt;'oFilename2.writeline "Log Started " &amp;amp; sDate&lt;BR&gt;'oFilename2.writeblanklines 1&lt;/P&gt;
&lt;P&gt;'Read external list of computers and check their status&lt;BR&gt;DO While oFilename1.AtEndOfStream &amp;lt;&amp;gt; True&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strComputer = oFileName1.ReadLine&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF GetComputerStatus(strComputer) = 1 Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'sComputerStatus = "Online"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objGroup = GetObject("WinNT://" &amp;amp; strComputer &amp;amp; "/Administrators,group")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sComputerStatus = EnumGroup(objGroup, "")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sComputerStatus = "Computer Could Not Be Contacted"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End IF&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oFilename2.writeline strCOmputer &amp;amp; vbTab &amp;amp; sComputerStatus&lt;BR&gt;Loop&lt;/P&gt;
&lt;P&gt;'OPTIONAL LOG FOOTER&lt;BR&gt;'sDate = Now()&lt;BR&gt;'oFilename2.writeblanklines 2&lt;BR&gt;'oFilename2.writeline "Log Completed " &amp;amp; sDate&lt;/P&gt;
&lt;P&gt;'Close input file&lt;BR&gt;oFilename1.close&lt;BR&gt;'Close Log file&lt;BR&gt;oFilename2.close&lt;/P&gt;
&lt;P&gt;'Wscript.echo "Finished Scanning Computers" 'open log file&lt;BR&gt;oWshShell.run "notepad.exe .\" &amp;amp; sOutPutFile, 5, FALSE&lt;/P&gt;
&lt;P&gt;Set oWshShell = Nothing&lt;BR&gt;Set oFSO = Nothing&lt;BR&gt;Set oExec = Nothing&lt;BR&gt;Set oFilename1 = Nothing&lt;BR&gt;Set oFilename2 = Nothing&lt;/P&gt;
&lt;P&gt;Function GetComputerStatus (strComputer)&lt;BR&gt;&amp;nbsp; 'Function Returns a 1 if computer is available&lt;BR&gt;&amp;nbsp; 'Used to determine if a computer is online before &lt;BR&gt;&amp;nbsp; 'attempting WMI connection&lt;BR&gt;&amp;nbsp; 'IP Address or computer name can be used&lt;BR&gt;&amp;nbsp; Dim sStatus&lt;BR&gt;&amp;nbsp; sStatus = 0&lt;BR&gt;'&amp;nbsp;&amp;nbsp; wscript.echo "Echo strCOmputer - " &amp;amp; strcomputer&lt;BR&gt;&amp;nbsp; Set oWshShell = Wscript.CreateObject("Wscript.Shell")&lt;BR&gt;&amp;nbsp; Set oExec = oWshShell.Exec("ping -n 2 -w 1000&amp;nbsp; " &amp;amp; strComputer)&lt;BR&gt;&amp;nbsp; strPingStdOut = oExec.StdOut.ReadAll&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If InStr(1,strPingStdOut, "reply from ",1) &amp;lt;&amp;gt; 0 Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sStatus = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sStatus = 0 &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End IF&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetComputerStatus = sStatus&lt;BR&gt;&amp;nbsp;END FUNCTION&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&lt;BR&gt;Function EnumGroup(objGroup, strOffset)&lt;BR&gt;&amp;nbsp;&amp;nbsp; Dim objMember, strMembers&lt;BR&gt;&amp;nbsp;&amp;nbsp; For Each objMember In objGroup.Members&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMembers = strmembers &amp;amp; strOffset &amp;amp; objMember.Name &amp;amp;&amp;nbsp; ", "&lt;BR&gt;&amp;nbsp;&amp;nbsp; Next&lt;BR&gt;&amp;nbsp; EnumGroup = strMembers&lt;BR&gt;End Function&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sample INPUT.TXT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Computer1&lt;BR&gt;Computer2&lt;BR&gt;Computer3&lt;BR&gt;Computer4&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Sample Input_RESULTS.TX&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Computer1&amp;nbsp;Computer Could Not Be Contacted&lt;BR&gt;Computer2&amp;nbsp;Administrator, Administrator, Domain Admins, SMS_ADMIN, &lt;BR&gt;Computer3&amp;nbsp;Administrator, Domain Admins, Administrator, SMS_ADMIN, &lt;BR&gt;Computer4&amp;nbsp;Administrator, Domain Admins, Administrator, SMS_ADMIN, &lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8996652" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Modifying Security on Active Directory Objects using a script</title><link>http://blogs.msdn.com/muaddib/archive/2007/12/14/modifying-security-on-active-directory-objects-using-a-script.aspx</link><pubDate>Fri, 14 Dec 2007 22:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6771951</guid><dc:creator>MuadDib</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/6771951.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=6771951</wfw:commentRss><description>&lt;P&gt;I was working with a customer this week and we found some user objects in Active Directory&amp;nbsp;had incorrect security settings.&amp;nbsp; I put together a list of commands for the customer to use.&amp;nbsp;&amp;nbsp;I thought a few of the FOR command examples below were useful so here you go...&amp;nbsp; &lt;/P&gt;
&lt;P&gt;These command can also be used in a script.&amp;nbsp; Keep in mind the FOR command syntax changes slightly (FOR /?) when used within a batch file.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DUMP CNs for all users in an OU&amp;nbsp;&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; DSQUERY USER "ou=test accounts, dc=contoso,dc=local"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Show security&amp;nbsp;for an object in Active Directory&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; DSACLS "cn=Jane doe1,ou=test accounts, dc=contoso,dc=local"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Show security&amp;nbsp;for&amp;nbsp;the&amp;nbsp;SELF&amp;nbsp;security principle&amp;nbsp;on an object in Active Directory&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; DSACLS "cn=Jane doe1,ou=test accounts, dc=contoso,dc=local" | find /i "self"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Use DSACLS on list of users in a file &lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; FOR /F "tokens=* usebackq"&amp;nbsp; %i in (`type users.txt`) DO dsacls %i &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (NOTE ` is a back quote found on same key as ~)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Use DSACLS on output of DSQUERY USERS &amp;lt;OU&amp;nbsp; DN&amp;gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; FOR /F "tokens=* usebackq"&amp;nbsp; %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (NOTE ` is a back quote found on same key as ~)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; FOR /F "tokens=* usebackq"&amp;nbsp; %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i | find /i "self"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (NOTE ` is a back quote found on same key as ~)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Reset a user to the default permissions as defined by the schema &lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; DSACLS "cn=jane doe1,ou=test accounts,dc=contoso,dc=local" /S (case sensitive)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Perfrom same task for all users in an OU&amp;nbsp; &lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; FOR /F "tokens=* usebackq"&amp;nbsp; %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i /S&amp;nbsp; (case sensitive)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6771951" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Reference/default.aspx">Reference</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Send Email from a Script</title><link>http://blogs.msdn.com/muaddib/archive/2007/04/16/send-email-from-a-script.aspx</link><pubDate>Mon, 16 Apr 2007 15:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2153822</guid><dc:creator>MuadDib</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/2153822.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=2153822</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Scripts are great for automating tasks that you need to perform on a regular basis.&amp;nbsp;&amp;nbsp;With a few lines of code you add the ability to send an email from within your scripts to notify you of a particular event.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;From a programming standpoint, there&amp;nbsp;are two ways to send a script programmatically.&amp;nbsp; The first involves using the Simple Mail Transport Protocol (SMTP) service installed on the computer where the script runs.&amp;nbsp; The second method involves using another SMTP server to forward you emails.&amp;nbsp; I prefer the latter since you only need one computer running SMTP to send emails instead of installing the service on a number of computers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Before you can use the script you must locate a server running SMTP.&amp;nbsp; Check with your mail administrator and see if you can use one of the mail servers to forward emails.&amp;nbsp; If you don't have a server running SMTP you can add it to one of your existing servers.&amp;nbsp; In Windows Server 2003 SMTP is installed as part of the POP3 service.&amp;nbsp; To install the POP3 service open&amp;nbsp;Control Panel &amp;gt; Add or Remove Programs &amp;gt; Add/Remove Windows Components then select Email Services.&amp;nbsp; Click the details button and check the box next to POP3 Service.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Once the service has been installed you need to configure it so it will relay emails.&amp;nbsp;&amp;nbsp;Open IIS Manager, right-click "Default SMTP Server" and select properties.&amp;nbsp; Click the "Access" tab and select the "Relay..." button.&amp;nbsp; Select the "Only the list below" radio button and configure the servers that will be allowed to relay emails on this server.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Now that you have an SMTP server you need a script.&amp;nbsp; The script below is the one I used.&amp;nbsp; I created a function called "SendEmail" and&amp;nbsp;I pass it the subject (sSubject)&amp;nbsp;and body text (sPageText)&amp;nbsp;as arguments.&amp;nbsp; By creating a function, I can reuse this block of code in multiple scripts.&amp;nbsp; I have hard coded the "from address" (oEmail.From), "to address" (oEmail.To), and SMTP server (app1.lab.local).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;OPTION EXPLICIT&lt;BR&gt;Dim sPageText, sSubject&lt;BR&gt;ON ERROR RESUME NEXT&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;sSubject = "ALERT - UPS SHUTDOWN"&lt;BR&gt;sPagetext = NOW() &amp;amp; "&amp;nbsp;&amp;nbsp; The UPS has shutdown due to low battery.&amp;nbsp; UPSDOWN.CMD script was fired."&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;'Send Email&lt;BR&gt;SendEmail sSubject, sPageText&lt;/P&gt;
&lt;P&gt;Function SendEmail (sSubjectText,sBodyText)&lt;BR&gt;&amp;nbsp; &amp;nbsp; Dim oEmail&lt;BR&gt;&amp;nbsp; &amp;nbsp; Set oEmail = CreateObject("CDO.Message")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.From = "&lt;A href="mailto:ADMIN@lab.local" mce_href="mailto:ADMIN@lab.local"&gt;ADMIN@lab.local&lt;/A&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.To = "&lt;A href="mailto:RemoteAdmin@yourdomain.com" mce_href="mailto:RemoteAdmin@yourdomain.com"&gt;RemoteAdmin@yourdomain.com&lt;/A&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Subject = sSubjectText &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Textbody = sBodyText&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Configuration.Fields.Item _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ("&lt;A href="http://schemas.microsoft.com/cdo/configuration/sendusing" mce_href="http://schemas.microsoft.com/cdo/configuration/sendusing"&gt;http://schemas.microsoft.com/cdo/configuration/sendusing&lt;/A&gt;") = 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Configuration.Fields.Item _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ("&lt;A href="http://schemas.microsoft.com/cdo/configuration/smtpserver" mce_href="http://schemas.microsoft.com/cdo/configuration/smtpserver"&gt;http://schemas.microsoft.com/cdo/configuration/smtpserver&lt;/A&gt;") = _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "app1.lab.local" &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Configuration.Fields.Item _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ("&lt;A href="http://schemas.microsoft.com/cdo/configuration/smtpserverport" mce_href="http://schemas.microsoft.com/cdo/configuration/smtpserverport"&gt;http://schemas.microsoft.com/cdo/configuration/smtpserverport&lt;/A&gt;") = 25&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Configuration.Fields.Update&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oEmail.Send&lt;BR&gt;END FUNCTION&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;U&gt;&lt;/U&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;U&gt;Resources&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Sending E-Mail Without Installing the SMTP Service&lt;BR&gt;&lt;A href="http://www.microsoft.com/technet/scriptcenter/guide/sas_ent_wbpa.mspx?mfr=true" mce_href="http://www.microsoft.com/technet/scriptcenter/guide/sas_ent_wbpa.mspx?mfr=true"&gt;http://www.microsoft.com/technet/scriptcenter/guide/sas_ent_wbpa.mspx?mfr=true&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2153822" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Controlling Virtual Machines with a Script</title><link>http://blogs.msdn.com/muaddib/archive/2007/04/16/controlling-virtual-machines-with-a-script.aspx</link><pubDate>Mon, 16 Apr 2007 14:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2153056</guid><dc:creator>MuadDib</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/2153056.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=2153056</wfw:commentRss><description>&lt;P&gt;I discovered how easy it is to control virtual machines with a script this weekend.&amp;nbsp; I have one server that I use to run virtual machines that I keep running all the time.&amp;nbsp;&amp;nbsp;When I patch this server, I need to shut down all VMs before it is restarted and then restart the VMs after the computer starts.&amp;nbsp; After doing a quick search I discovered it only takes a few lines of code to shutdown or start a VM.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Shutdown a server named Server1&lt;BR&gt;&lt;/STRONG&gt;On Error Resume Next&lt;BR&gt;Set objVS = CreateObject("VirtualServer.Application")&lt;BR&gt;Set objVM = objVS.FindVirtualMachine("Server1")&lt;BR&gt;Set objGuestOS = objVM.GuestOS&lt;BR&gt;objGuestOS.Shutdown()&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Startup a server named Server1&lt;BR&gt;&lt;/STRONG&gt;On Error Resume Next&lt;BR&gt;Set objVS = CreateObject("VirtualServer.Application")&lt;BR&gt;Set objVM = objVS.FindVirtualMachine("Server1")&lt;BR&gt;objVM.Startup()&lt;/P&gt;
&lt;P&gt;If you have multiple VMs you can put them all in the same script as shown below:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;On Error Resume Next&lt;BR&gt;Set objVS = CreateObject("VirtualServer.Application")&lt;BR&gt;Set objVM = objVS.FindVirtualMachine("Server1")&lt;BR&gt;Set objGuestOS = objVM.GuestOS&lt;BR&gt;objGuestOS.Shutdown()&lt;BR&gt;sleep 15000&lt;BR&gt;Set objVS = CreateObject("VirtualServer.Application")&lt;BR&gt;Set objVM = objVS.FindVirtualMachine("Server2")&lt;BR&gt;Set objGuestOS = objVM.GuestOS&lt;BR&gt;objGuestOS.Shutdown()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So to make things easier on me&amp;nbsp;I wrote two simple scripts; one that starts the VMs and one that stops them.&amp;nbsp; I then configured a local policy on the server to run the&amp;nbsp;script that starts the VMs as a "Startup Script" so the VMs would start automatically every time the server is started.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Virtual Machine and Virtual Server Properties &lt;BR&gt;&lt;/STRONG&gt;&lt;A href="http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true" mce_href="http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true"&gt;http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2153056" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Script Code Link Added</title><link>http://blogs.msdn.com/muaddib/archive/2007/01/03/script-code-link-added.aspx</link><pubDate>Thu, 04 Jan 2007 03:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1407785</guid><dc:creator>MuadDib</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/1407785.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=1407785</wfw:commentRss><description>&lt;P&gt;I have a link in the left navigation bar to a page where I will begin posting some scripts I have written.&amp;nbsp; I have written several useful scripts over the years and I'll post them here as time permits.&amp;nbsp; The scripts will mostly be VBscript using WMI and ADSI scripting interfaces to retrieve information from computers and Active Directory.&amp;nbsp; You might also find a couple of batch files mixed in.&amp;nbsp; Down the road I will post some Pwershell Scripts and tips as I come up to speed on this new scripting/administration interface.&amp;nbsp; A link to the modest beginning is shown below.&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/muaddib/pages/useful-scripts.aspx" mce_href="http://blogs.msdn.com/muaddib/pages/useful-scripts.aspx"&gt;Script Code&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1407785" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item><item><title>Automate Network Adapter Configuration using NETSH</title><link>http://blogs.msdn.com/muaddib/archive/2006/10/24/automate-network-adapter-configuration-using-netsh.aspx</link><pubDate>Tue, 24 Oct 2006 18:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:868792</guid><dc:creator>MuadDib</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/muaddib/comments/868792.aspx</comments><wfw:commentRss>http://blogs.msdn.com/muaddib/commentrss.aspx?PostID=868792</wfw:commentRss><description>&lt;P&gt;So I'm kind of lazy.&amp;nbsp; Not in the "sleep late and don't go to work"&amp;nbsp;slacker way, I just&amp;nbsp;don't like doing dull r&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;epetitive tasks if they can be automated in some way.&amp;nbsp; As a rule if I have to do the same task more than a couple of times I'm writing a script (or getting someone else to do it).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;During the years I worked as a consultant it was not uncommon to connect my laptop to several&amp;nbsp;different networks in the same day.&amp;nbsp; In some cases they were DHCP enabled so connection was easy.&amp;nbsp; For others I would have to configure the network adapter manually.&amp;nbsp;&amp;nbsp;Ugh!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Enter the NETSH commands.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;The NETSH command can be used to modify the network configuration on Windows 2000 and later computers.&amp;nbsp; It's not the friendliest syntax&amp;nbsp;to use but it is a real time saver once you learn to use it (I have noticed the version that ships with Vista seems almost intuitive).&amp;nbsp; Listed below are sample script for using NETSH to set STATIC IP entries on an adapter and another script to set the adapter back to DHCP mode so the settings can be obtained automatically.&amp;nbsp; The command syntax for Vista and XP are slight different due to the fact that Vista supports IPV6 natively so sample scripts for each OS&amp;nbsp;are listed below.&amp;nbsp; To use the code, paste it&amp;nbsp;into a batch file and modify the "name=" to the name of the adapter in quotes and change the&amp;nbsp;IP addresses. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;STRONG&gt;&lt;U&gt;&amp;nbsp;VISTA - Static IP&lt;/U&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;netsh interface ipv4 set address name="Wireless Network Connection 2" source=static addr=192.168.0.100 mask=255.255.255.0 gateway=192.168.0.250 gwmetric=0&lt;BR&gt;netsh interface ipv4 set dnsserver name="Wireless Network Connection 2" source=static addr=192.168.0.2 register=NONE&lt;BR&gt;REM netsh interface ipv4 set wins name="Wireless Network Connection 2" source=static addr=155.217.27.9&lt;BR&gt;REM&amp;nbsp; OR if no WINS server&lt;BR&gt;netsh interface ipv4 set winsserver name="Wireless Network Connection 2" source=dhcp&lt;BR&gt;ipconfig /all&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;STRONG&gt;&lt;U&gt;VISTA - DHCP&lt;/U&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;netsh interface ipv4 set address name="Wireless Network Connection 2" source=dhcp&lt;BR&gt;netsh interface ipv4 set dnsserver name="Wireless Network Connection 2" source=dhcp&lt;BR&gt;netsh interface ipv4 set winsserver name="Wireless Network Connection 2" source=dhcp&lt;BR&gt;ipconfig /renew "Wireless Network Connection 2"&lt;BR&gt;ipconfig /all&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;STRONG&gt;&lt;U&gt;XP - Static IP&lt;/U&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;netsh interface ip set address name="BROADCOM" source=static addr=192.168.27.40 mask=255.255.255.224&lt;BR&gt;netsh interface ip set address name="BROADCOM" gateway=192.168.27.33 gwmetric=0&lt;BR&gt;netsh interface ip set dns name="BROADCOM" source=static addr=192.168.98.12 register=NONE&lt;BR&gt;netsh interface ip set wins name="BROADCOM" source=static addr=none&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;STRONG&gt;&lt;U&gt;XP - DHCP&lt;/U&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;netsh interface ip set address name="BROADCOM" dhcp&lt;BR&gt;netsh interface ip set dns name="BROADCOM source = dhcp&lt;BR&gt;netsh interface ip set wins name="BROADCOM" source=dhcp&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=868792" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/muaddib/archive/tags/Time+Savers/default.aspx">Time Savers</category><category domain="http://blogs.msdn.com/muaddib/archive/tags/Script/default.aspx">Script</category></item></channel></rss>