<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JJClements.co.uk &#187; Windows Server 2003</title>
	<atom:link href="http://www.jjclements.co.uk/category/windows-server-2003/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jjclements.co.uk</link>
	<description>Clem&#039;s Technical Blog</description>
	<lastBuildDate>Tue, 08 Jun 2010 22:26:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Windows Server time synchronization</title>
		<link>http://www.jjclements.co.uk/2010/04/15/windows-server-time-synchronization/</link>
		<comments>http://www.jjclements.co.uk/2010/04/15/windows-server-time-synchronization/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 09:08:58 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[nt5ds]]></category>
		<category><![CDATA[ntp]]></category>
		<category><![CDATA[pdc]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[w32time]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=781</guid>
		<description><![CDATA[Something I have frequently seen implemented incorrectly on Windows Server domains is time synchronization. Many admins think that by creating a GPO with a modified policy setting for 'Configure Windows NTP Client' (and using it to address an NTP source) all Servers and Clients will synchronize their time with that source. This isn't entirely true [...]]]></description>
			<content:encoded><![CDATA[<p>Something I have frequently seen implemented incorrectly on Windows Server domains is time synchronization. Many admins think that by creating a GPO with a modified policy setting for 'Configure Windows NTP Client' (and using it to address an NTP source) all Servers and Clients will synchronize their time with that source. This isn't entirely true and there is actually a time hierarchy that should be considered when implementing time synchronization for each domain.</p>
<p><span id="more-781"></span></p>
<p>As far as W32Time (the Windows time service) is concerned, at the topmost level within the domain is the domain controller on which the <a rel="nofollow" href="http://en.wikipedia.org/wiki/Primary_Domain_Controller#Windows_2000:_PDC_emulation" target="_blank">PDC Emulator</a> Flexible Single Master Operation <a rel="nofollow" href="http://en.wikipedia.org/wiki/Flexible_single_master_operation" target="_blank">(FSMO)</a> role resides. This can be configured to synchronize it's time with a <a rel="nofollow" href="http://www.pool.ntp.org/en" target="_blank">reliable external time source</a>. By default all other domain controllers internally synchronize their time with the PDC Emulator. Similarly all domain member client computers synchronize their time with the domain controller that authenticates them.</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2010/04/timesync.png" alt="timesync.png" /></p>
<p>Configuring the domain controller where the PDC Emulator role resides should be the only computer in the domain that requires any manual intervention to have the precise time on all domain client computers.</p>
<p>To find out which server the PDC Emulator role resides on open the Active Directory Users and Computers (ADUC) snap-in. Then right click on your domain and select 'Operations Masters'. Browsing the PDC tab will show you where the PDC Emulator role currently resides.</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2010/04/pdcemulator.png" alt="pdcemulator.png" /></p>
<p>On the domain controller where the PDC Emulator resides you can configure it to synchronize its time with an external source by using the following command:</p>
<p><strong>net time /setsntp:&lt;ip/dns&gt;</strong></p>
<p>Use the following example to set multiple external time sources to sync with:</p>
<p><strong>net time /setsntp:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"</strong></p>
<p>You can also configure this manually by modifying the following registry key:</p>
<p>HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters</p>
<p><strong>NtpServer=&lt;ip/dns&gt;</strong><br />
<strong>Type=NT5DS</strong> change this to <strong>Type=NTP</strong></p>
<p>After making the above changes restart the W32Time service by issuing the following commands at a command prompt:</p>
<p><strong>net stop w32time</strong><br />
<strong>net start w32time</strong></p>
<p>NOTE: If you don't configure the PDC Emulator to synchronize its time with an external source it will simply use its own (CMOS) clock. Doing so will occasionally cause an error to appear in the event log on the server that resembles the following:</p>
<blockquote><p>
Event Type: Error<br />
Event Source: W32Time<br />
Event Category: None<br />
Event ID: 12</p>
<p>Event description: Time Provider NtpClient: This machine is configured to use the domain hierarchy to determine its time source, but it is the PDC emulator for the domain at the root of the forest, so there is no machine above it in the domain hierarchy to use as a time source.
</p></blockquote>
<p>NOTE: If you experience a client with time synchronization problems ensure that it has the correct time zone set. If needed, the time service can be reset using the following commands:</p>
<p><strong>net stop w32time</strong><br />
<strong>w32tm /unregister</strong><br />
<strong>w32tm /register</strong><br />
<strong>net start w32time</strong><br />
<strong>w32tm /resync</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2010/04/15/windows-server-time-synchronization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Black logon box and text fields on Windows Server 2003</title>
		<link>http://www.jjclements.co.uk/2009/07/08/black-logon-box-and-text-fields-on-windows-server-2003/</link>
		<comments>http://www.jjclements.co.uk/2009/07/08/black-logon-box-and-text-fields-on-windows-server-2003/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 11:16:53 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Registry]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[logon]]></category>
		<category><![CDATA[msgina]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=279</guid>
		<description><![CDATA[I had a problem the other day when I went to logon to a server using RDP and the text fields where you enter your username and password were black! I typed in my credentials anyway and found that I could still logon to the server. After this there seemed to be no other issues. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a problem the other day when I went to logon to a server using RDP and the text fields where you enter your username and password were black! I typed in my credentials anyway and found that I could still logon to the server. After this there seemed to be no other issues.</p>
<p><span id="more-279"></span></p>
<p>Here is what I was presented with when I tried to logon:</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2009/07/blacklogon.png" alt="blacklogon.png" /></p>
<p>Around the time it happened I remember the OS volume running extremely low on space and figured it may be a corrupt user profile. So I renamed the profile and then tried to logon to the server again using Remote Desktop. I was again presented with the same logon screen with black text fields. After a quick search on the Microsoft knowledge base I came across an article that seemed to offer a workaround:</p>
<p><a href="http://support.microsoft.com/kb/906510" target="_blank" rel="nofollow">KB906510</a></p>
<p>I had a quick check of the HKEY_USERS\.Default\Control Panel\Colors registry key and surely enough lots of the colours were set to "0 0 0":</p>
<p>[HKEY_USERS\.DEFAULT\Control Panel\Colors]<br />
"ActiveBorder"="212 208 200"<br />
"ActiveTitle"="10 36 106"<br />
"AppWorkSpace"="128 128 128"<br />
"Background"="102 111 116"<br />
"ButtonAlternateFace"="181 181 181"<br />
"ButtonDkShadow"="64 64 64"<br />
"ButtonFace"="212 208 200"<br />
"ButtonHilight"="255 255 255"<br />
"ButtonLight"="212 208 200"<br />
"ButtonShadow"="128 128 128"<br />
"ButtonText"="0 0 0"<br />
"GradientActiveTitle"="166 202 240"<br />
"GradientInactiveTitle"="192 192 192"<br />
"GrayText"="128 128 128"<br />
"Hilight"="10 36 106"<br />
"HilightText"="255 255 255"<br />
"HotTrackingColor"="0 0 128"<br />
"InactiveBorder"="0 0 0"<br />
"InactiveTitle"="0 0 0"<br />
"InactiveTitleText"="0 0 0"<br />
"InfoText"="0 0 0"<br />
"InfoWindow"="0 0 0"<br />
"Menu"="0 0 0"<br />
"MenuText"="0 0 0"<br />
"Scrollbar"="0 0 0"<br />
"TitleText"="0 0 0"<br />
"Window"="0 0 0"<br />
"WindowFrame"="0 0 0"<br />
"WindowText"="0 0 0"<br />
"MenuHilight"="0 0 0"<br />
"MenuBar"="0 0 0"</p>
<p>I exported the same registry key from another server (that wasn't affected) and imported it into the registry of the server that was displaying the black logon screen. After logging off and back onto the server (no reboot necessary) the colours had returned to what they were previously:</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2009/07/normallogon.png" alt="normallogon.png" /></p>
<p>The registry key values I exported came from a Server running Server 2003 Enterprise Edition but I have compared them to those of Server 2003 Standard Edition and they are the same. You can download the correct registry values from here:</p>
<p><a href="http://www.jjclements.co.uk/wp-content/uploads/2009/07/logoncolourfix.reg" target="_blank" rel="nofollow">Download registry values for KB906510</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2009/07/08/black-logon-box-and-text-fields-on-windows-server-2003/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remote Control Terminal Services RDP Session</title>
		<link>http://www.jjclements.co.uk/2009/06/24/remote-control-terminal-services-rdp-session/</link>
		<comments>http://www.jjclements.co.uk/2009/06/24/remote-control-terminal-services-rdp-session/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:30:08 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Terminal Services]]></category>
		<category><![CDATA[Windows Server 2003]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=244</guid>
		<description><![CDATA[I am frequently asked to allow access to our servers for 3rd party company usually trying to fix some sort of software issue in their application (the typical scenario.) Most companies tend to use applications such as GoToMeeting or Live Meeting which I’ve never really been in favour of. Recently I was told that in [...]]]></description>
			<content:encoded><![CDATA[<p>I am frequently asked to allow access to our servers for 3rd party company usually trying to fix some sort of software issue in their application (the typical scenario.) Most companies tend to use applications such as GoToMeeting or Live Meeting which I’ve never really been in favour of. Recently I was told that in order for a new implementation to commence I would have to give a company VPN access to our network and Remote Desktop Connections onto the relevant servers.</p>
<p><span id="more-244"></span></p>
<p>On this occasion I decided to enable Remote Control of remote sessions on the servers so that I could see exactly what the company was doing on our servers. I’ve done this a few times before, namely back when I setup terminal services. After a little digging around I remembered the setting!</p>
<p>Note – These settings can be applied using 2 methods. One way is by using a GPO applied to the server(s) in question. This can be achieved by opening group policy and navigating to:</p>
<p>Computer Configuration -> Administrative Templates -> Windows Components -> Terminal Services</p>
<p>Double-click the 'Set rules for remote control of Terminal Services user sessions' setting and then enable it. Now, in the 'Options' box select the desired remote control permissions and apply the settings:</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2009/06/gpoconfig.png" alt="gpoconfig.png" /></p>
<p>The other way is to manually change the setting on the server itself by opening the ‘Terminal Services Configuration’ Snap-in:</p>
<p>Start -> (All Programs) -> Administrative Tools -> Terminal Services Configuration</p>
<p>Now select connections from the configuration tree on the left and in the right hand pane right click on the ‘RDP-Tcp’ connection and select properties:</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2009/06/tsconfig.png" alt="tsconfig.png" /></p>
<p>After opening the properties dialog select ‘Remote Control’ from the tabs at the top. Now change:</p>
<p>‘Use remote control with default user settings’ (the default setting)</p>
<p>To</p>
<p>‘Use remote control with the following settings:’</p>
<p>I uncheck ‘require user’s permission’ and choose to ‘Interact with the session’ so that I can take control at any time should I need to:</p>
<p><img src="http://www.jjclements.co.uk/wp-content/uploads/2009/06/rdpsettings.png" alt="rdpsettings.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2009/06/24/remote-control-terminal-services-rdp-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KiXtart script to generate and email uptime report</title>
		<link>http://www.jjclements.co.uk/2009/03/10/kixtart-script-to-generate-and-email-uptime-report/</link>
		<comments>http://www.jjclements.co.uk/2009/03/10/kixtart-script-to-generate-and-email-uptime-report/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 11:05:26 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=178</guid>
		<description><![CDATA[As part of my Service Level Agreement at work I have to produce a monthly uptime report for each server. Rather than generate individual reports for each server I decided to write a KiXtart script that would generate a report for all servers and email it to me each month. The following script uses two [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my Service Level Agreement at work I have to produce a monthly uptime report for each server. Rather than generate individual reports for each server I decided to write a <a href="http://www.kixtart.org" target="_blank" rel="nofollow">KiXtart</a> script that would generate a report for all servers and email it to me each month.</p>
<p><span id="more-178"></span></p>
<p>The following script uses two other applications:</p>
<p><a href="http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm" target="_blank" rel="nofollow">BMail</a> - A command line SMTP mailing tool<br />
<a href="http://support.microsoft.com/kb/232243" target="_blank" rel="nofollow">Uptime</a> - Allows you to estimate Server availability</p>
<p>Full credit to Craig Peacock for BMail.</p>
<p>Here is the script:</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Clear Existing Uptime Report<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>IF EXIST ("Report")<br />
DEL "Report\*.txt"<br />
ENDIF</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Produce Uptime Report<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>;Convert YYYY/MM/DD to DD-MM-YYYY<br />
$temp = @DATE<br />
$todaysdate = SUBSTR($temp, 9, 2)<br />
$todaysdate = $todaysdate + "-" + SUBSTR($temp, 6, 2)<br />
$todaysdate = $todaysdate + "-" + SUBSTR($temp, 1, 4)</p>
<p>;Array containing server names<br />
Dim $ComputerNames[5]<br />
$ComputerNames[0] = "Server01"<br />
$ComputerNames[1] = "Server02"<br />
$ComputerNames[2] = "Server03"<br />
$ComputerNames[3] = "Server04"<br />
$ComputerNames[4] = "Server05"</p>
<p>;If Report directory doesn't exist then create it<br />
IF NOT EXIST ("Report")<br />
MD "Report"<br />
ENDIF</p>
<p>;Output uptime report for all computers in the array<br />
For Each $Element In $ComputerNames</p>
<p>IF $Element = ""<br />
GoTo "Email"<br />
ENDIF</p>
<p>shell "%comspec% /c " + chr(34) + "Uptime.exe" + " " + $Element + " " + chr(34) + " /s /p:31 >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo. >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo. >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo ******************************************************************************** >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo ******************************************************************************** >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo ******************************************************************************** >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo. >> Report\$todaysdate-UptimeReport.txt"<br />
shell "%comspec% /c echo. >> Report\$todaysdate-UptimeReport.txt"</p>
<p>Next</p>
<p>:Email<br />
;===============================================<br />
;===============================================<br />
;<br />
;         Email Uptime Report<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$emailserver = "someemailserver"<br />
$toaddress = "james" + chr(64) + "somedomain.com"<br />
$fromaddress = "uptime" + chr(64) + "somedomain.com"<br />
$subject = "Uptime Report For all London Servers"</p>
<p>;Form email command<br />
$emailcommand = "bmail -s " + $emailserver + " -t " + $toaddress + " -f " + $fromaddress + " -h -a " + chr(34) + $subject + chr(34) + " -m " + "Report\" + $todaysdate + "-UptimeReport.txt" + " -c"</p>
<p>RUN ($emailcommand)</p>
<p>;===============================================</p>
<p>The script works by generating a file that contains the results of uptime.exe for each server specified. The contents of the file are then emailed using bmail.</p>
<p>This script obviously requires a few variables to be modified to get it to work in another environment. The following will need to be altered:</p>
<p>Dim $ComputerNames[5] - you will need to change the numeric value to the number of servers you want to generate a report for</p>
<p>NOTE: the example above is for 5 servers. If you wanted to monitor 4 servers then you will need to modify the array to change the number of elements to 4. So your array would look like (the last line has been removed):</p>
<p>$ComputerNames[0] = "Server01"<br />
$ComputerNames[1] = "Server02"<br />
$ComputerNames[2] = "Server03"<br />
$ComputerNames[3] = "Server04"</p>
<p>$ComputerNames[0] = "Server01" - you need to change Server01 to the server you want to generate a report for<br />
$emailserver - the name of your email server (the server running this script must be allowed to relay through it)<br />
$toaddress - the address you want the email alert to go to<br />
$fromaddress - the (spoof) address you want the email to appear to come from<br />
$subject - the subject line of the email</p>
<p>I use a scheduled task on a Windows Server 2003 to run this script once a month. It generates a report for the last 31 days of uptime for each server in the array and then emails me the report.</p>
<p>NOTE: you can change 31 day period that the script gathers uptime information for by modifying /p:31 on the following line:</p>
<p>(31 represents the number of days in the past to gather uptime statistics for)</p>
<p>shell "%comspec% /c " + chr(34) + "Uptime.exe" + " " + $Element + " " + chr(34) + " /s /p:31 >> Report\$todaysdate-UptimeReport.txt"</p>
<p>To use this:</p>
<p>1) Save the above script as kixtart.kix in a directory containing the kixtart application<br />
2) Save bmail.exe and uptime.exe (available from the links above) in the same directory<br />
3) Modify variables as appropriate<br />
4) Make sure that the server running the script can relay email through your email server<br />
5) Test by running the script manually and/or create the scheduled task</p>
<p>Alternatively, download the above script and necessary files - <a href="http://www.jjclements.co.uk/wp-content/uploads/2009/03/uptime-report.zip" target="_blank" rel="nofollow">HERE</a></p>
<p>The end result is an email with a breakdown of uptime availability for each server including any dates and times where necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2009/03/10/kixtart-script-to-generate-and-email-uptime-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KiXtart script to check for website availability</title>
		<link>http://www.jjclements.co.uk/2009/02/19/kixtart-script-to-check-for-website-availability/</link>
		<comments>http://www.jjclements.co.uk/2009/02/19/kixtart-script-to-check-for-website-availability/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 12:06:42 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[SLA]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=130</guid>
		<description><![CDATA[At work there is an old web application that is managed offsite by a hosting company. It runs on Oracle 9iAS. Apparently there is an issue with Oracle 9i and the web service will frequently crash (due to a known caching problem) taking the application offline. Rather than spending money on the software and licensing [...]]]></description>
			<content:encoded><![CDATA[<p>At work there is an old web application that is managed offsite by a hosting company. It runs on Oracle 9iAS. Apparently there is an issue with Oracle 9i and the web service will frequently crash (due to a known caching problem) taking the application offline.</p>
<p><span id="more-130"></span></p>
<p>Rather than spending money on the software and licensing required to upgrade both Oracle and the Operating System (as it's being replaced anyway) the company made a decision to live with the issue for the time being. I decided to write a <a href="http://www.kixtart.org" target="_blank" rel="nofollow">KiXtart</a> script to monitor the website and let me know of any issues it may incur.</p>
<p>The following script uses two other applications:</p>
<p><a href="http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm" target="_blank" rel="nofollow">BMail</a> - A command line SMTP mailing tool<br />
<a href="http://johnmu.com/web-toolbox-1/" target="_blank" rel="nofollow">WebResult</a> - A command line URL result code tool</p>
<p>Full credit to Craig Peacock for BMail and John Mueller for WebResult.</p>
<p>Here is the script:</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Remove temp files<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>IF EXIST ("result.txt")<br />
DEL ("result.txt")<br />
ENDIF</p>
<p>IF EXIST ("status.txt")<br />
DEL ("status.txt")<br />
ENDIF</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Check/record http status in result.txt<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$website = "http://www.jjclements.co.uk"</p>
<p>SHELL "%comspec% /c " + chr(34) + "webresult.exe " + $website + chr(34) + " >> result.txt"</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Open result.txt and read into variable<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>getfilecontents("result.txt")</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Explode variable into array<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$myarray = SPLIT ($result, "	", -1)</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Declare global variable to store desc<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$errordesc = ""</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Check each array element against codes<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$element = $myarray[1]<br />
 SELECT</p>
<p>  CASE $element = "0"<br />
  $errordesc = "The current status is: Error " + $element + " - Website Unavailable"</p>
<p>  CASE $element = "400"<br />
  $errordesc = "The current status is: Error " + $element + " - Bad Request"</p>
<p>  CASE $element = "403"<br />
  $errordesc = "The current status is: Error " + $element + " - Forbidden"</p>
<p>  CASE $element = "404"<br />
  $errordesc = "The current status is: Error " + $element + " - Not Found"</p>
<p>  CASE $element = "405"<br />
  $errordesc = "The current status is: Error " + $element + " - Method Not Allowed"</p>
<p>  CASE $element = "406"<br />
  $errordesc = "The current status is: Error " + $element + " - Not Acceptable"</p>
<p>  CASE $element = "408"<br />
  $errordesc = "The current status is: Error " + $element + " - Request Timeout"</p>
<p>  CASE $element = "409"<br />
  $errordesc = "The current status is: Error " + $element + " - Conflict"</p>
<p>  CASE $element = "410"<br />
  $errordesc = "The current status is: Error " + $element + " - Gone"</p>
<p>  CASE $element = "500"<br />
  $errordesc = "The current status is: Error " + $element + " - Internal Server Error"</p>
<p>  CASE $element = "501"<br />
  $errordesc = "The current status is: Error " + $element + " - Not Implemented"</p>
<p>  CASE $element = "502"<br />
  $errordesc = "The current status is: Error " + $element + " - Bad Gateway"</p>
<p>  CASE $element = "503"<br />
  $errordesc = "The current status is: Error " + $element + " - Internal Server Error"</p>
<p>  CASE $element = "504"<br />
  $errordesc = "The current status is: Error " + $element + " - Gateway Timeout"</p>
<p>  CASE $element = "505"<br />
  $errordesc = "The current status is: Error " + $element + " - HTTP Version not supported"</p>
<p>  CASE 1<br />
  EXIT</p>
<p> ENDSELECT</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Threshold - Times to retry + interval<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$numberofretries = "2"<br />
$latencyseconds = "10"</p>
<p>IF $numberofretries > "0"</p>
<p>DO</p>
<p>SLEEP $latencyseconds</p>
<p>IF EXIST ("result.txt")<br />
DEL ("result.txt")<br />
ENDIF</p>
<p>SHELL "%comspec% /c " + chr(34) + "webresult.exe " + $website + chr(34) + " >> result.txt"</p>
<p>getfilecontents("result.txt")</p>
<p>$mytemparray = SPLIT ($result, "	", -1)</p>
<p>$tempelement = $mytemparray[1]</p>
<p>IF NOT $element = $tempelement<br />
EXIT<br />
ENDIF</p>
<p>$currentretry = $currentretry + 1</p>
<p>UNTIL $numberofretries = $currentretry</p>
<p>ENDIF</p>
<p>;===============================================<br />
;===============================================<br />
;<br />
;         Email Server Status<br />
;<br />
;===============================================<br />
;===============================================</p>
<p>$emailserver = "someemailserver"<br />
$toaddress = "james" + chr(64) + "somedomain.com"<br />
$fromaddress = "serverfailure" + chr(64) + "somedomain.com"<br />
$subject = "Server Issue"</p>
<p>;Form email body<br />
shell "%comspec% /c echo. >> status.txt"<br />
shell "%comspec% /c echo. >> status.txt"<br />
shell "%comspec% /c echo WebServer is currently offline >> status.txt"<br />
shell "%comspec% /c echo. >> status.txt"<br />
shell "%comspec% /c echo " + $errordesc + " >> status.txt"<br />
shell "%comspec% /c echo. >> status.txt"<br />
shell "%comspec% /c echo Please restart the WebServer application to ensure SLAs are adhered to! >> status.txt"</p>
<p>;Form email command<br />
$emailcommand = "bmail -s " + $emailserver + " -t " + $toaddress + " -f " + $fromaddress + " -h -a " + chr(34) + $subject + chr(34) + " -m " + "status.txt" + " -c"</p>
<p>SHELL ($emailcommand)</p>
<p>;=======================================<br />
;	Get File Contents<br />
;=======================================</p>
<p>Function getfilecontents($filesource)</p>
<p>OPEN (1, "$filesource")<br />
$result = READLINE (1)<br />
CLOSE (1)</p>
<p>EndFunction</p>
<p>;=======================================</p>
<p>This script obviously requires a few variables to be modified to get it to work in another environment. The following will need to be altered:</p>
<p>$website - you will need to enter your own website you want to monitor here (you must use http://)<br />
$numberofretries - the number of times the script will test the website before emailing an error<br />
$latencyseconds - the time in seconds before each retry (if $numberofretries is NOT set to 0)<br />
$emailserver - the name of your email server (the server running this script must be allowed to relay through it)<br />
$toaddress - the address you want the email alert to go to<br />
$fromaddress - the (spoof) address you want the email to appear to come from<br />
$subject - the subject line of the email</p>
<p>The only other thing you may want to change is the message contained within the email (underneath ';Form email body'). I have a few instances of this script monitoring different servers so I have customised the email body for each server to inform me of the server name and IP address etc.</p>
<p>As mentioned the script makes use of a threshold although it isn't used if you set $numberofretries = "0". The threshold sets the number of times to try the website before sending an email. You can also set the delay between each retry (in seconds) by setting a value for $latencyseconds.</p>
<p>I use a scheduled task on a Windows Server 2003 to run this script every 5 minutes. When there is a problem with the web application I am alerted to it and can respond as necessary. One thing to be aware of, if you set your scheduled task to run every 5 minutes but you set the script to retry say 3 times with a latency of 120 seconds (total 360 seconds - 6 minutes) then the scheduled task will try to run again before the script has finished causing problems.</p>
<p>To use this: </p>
<p>1) Save the above script as kixtart.kix in a directory containing the kixtart application<br />
2) Save webresult.exe and bmail.exe (available from the links above) in the same directory<br />
3) Modify variables as appropriate<br />
4) Make sure that the server running the script can relay email through your email server<br />
5) Test by running the script manually and/or create the scheduled task</p>
<p>Alternatively, download the above script and necessary files - <a href="http://www.jjclements.co.uk/wp-content/uploads/2009/02/website-availability-script.zip" target="_blank" rel="nofollow">HERE</a></p>
<p>The end result is an email that tells you the exact http error code and description when your web application becomes unavailable and meets any threshold that may be set.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2009/02/19/kixtart-script-to-check-for-website-availability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delete files older than certain number of days</title>
		<link>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/</link>
		<comments>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 13:16:30 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[forfiles.exe]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/?p=66</guid>
		<description><![CDATA[I was recently asked to investigate a problem with a server and the lack of space on a partition. After a quick look using Treesize I noticed a suspicious folder being used by an application for logging purposes. There were over 700,000 files in it! When I tried to browse the folder using explorer it [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked to investigate a problem with a server and the lack of space on a partition. After a quick look using <a href="http://www.jam-software.com/freeware/index.shtml" target="_blank" rel="nofollow">Treesize</a> I noticed a suspicious folder being used by an application for logging purposes.</p>
<p><span id="more-66"></span></p>
<p>There were over 700,000 files in it! When I tried to browse the folder using explorer it took an absolute age to open as you can imagine. To rectify the problem and recover the majority of the disk space being used by the logs I wanted to delete the contents of the logging folder that was older than 30 days. After a quick search I discovered a command line utility called forfiles.exe that is included with Windows Server 2003. Using forfiles.exe I was able to delete all files older than 30 days like so:</p>
<p>forfiles.exe /p (pathtofilestodelete) /s /m *.* /d -30 /c "cmd /c del /q @path"</p>
<p>A working example is:</p>
<p>forfiles.exe /p d:\logs /s /m *.* /d -30 /c "cmd /c del /q @path"</p>
<p>This will delete ALL files from d:\logs (and all sub folders it contains because /s has been used to force recursion) older than 30 days without prompting you to confirm deletion.</p>
<p>Here is an explanation of the switches I used:</p>
<p>/p = The path to search for the files you want to check the date of and remove<br />
/s = Recurse subdirectories contained within the path specified using /p and check them as well<br />
/m = The search mask to be used for the file type you want to check the date on (*.* being all files)<br />
/d = The date to compare the files against. A standard date type can also be used (dd/mm/yyyy)<br />
/c = The command to be used on a file that matches the /m and /d criteria<br />
/q = Used within /c to instruct the del command to delete files quietly</p>
<p>Note: different operating systems came bundled with different versions of forfiles.exe. You will need to download the appropriate version of forfiles.exe for the operating system you wish to use it on.</p>
<p><a rel="nofollow" href="http://www.jjclements.co.uk/wp-content/uploads/2008/07/forfiles_Server_2000.zip" target="_blank">forfiles.exe - Windows Server 2000</a><br />
<a rel="nofollow" href="http://www.jjclements.co.uk/wp-content/uploads/2008/07/forfiles_Server_2003.zip" target="_blank">forfiles.exe - Windows Server 2003</a><br />
<a rel="nofollow" href="http://www.jjclements.co.uk/wp-content/uploads/2008/07/forfiles_Server_2008.zip" target="_blank">forfiles.exe - Windows Server 2008</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2008/07/31/delete-files-older-than-certain-number-of-days/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>RIS hard disk size problem</title>
		<link>http://www.jjclements.co.uk/2007/09/25/ris-hard-disk-size-problem/</link>
		<comments>http://www.jjclements.co.uk/2007/09/25/ris-hard-disk-size-problem/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 18:50:15 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[ris]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/index.php/2007/09/25/ris-hard-disk-size-problem/</guid>
		<description><![CDATA[A common problem I have encountered when using the legacy Remote Installation Services (RIS) to install operating system(s) onto new computers, is caused by the size of the hard disk that you wish to install the operating system onto. Put simply, if you have made a RIPREP image using RIS on a 40GB hard disk, [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem I have encountered when using the legacy Remote Installation Services (RIS) to install operating system(s) onto new computers, is caused by the size of the hard disk that you wish to install the operating system onto. </p>
<p><span id="more-32"></span></p>
<p>Put simply, if you have made a RIPREP image using RIS on a 40GB hard disk, RIS will only install this image onto a hard disk of equal size or bigger. Even if the operating system contains only 2GB worth of files, it makes no difference if you made the image on a 40GB drive, you still will not be able to install the operating system onto a drive smaller than 40GB.</p>
<p>The error you are presented with when you encounter this problem looks like this:</p>
<blockquote><p>"Setup cannot copy the operating system image you selected. </p>
<p>This computer does not have enough disk space on the selected partition.</p>
<p>Contact your system administrator"</p></blockquote>
<p>More info about the error can be found here:</p>
<p><a href="http://support.microsoft.com/kb/320982" target="_blank" rel="nofollow">Microsoft KB320982</a></p>
<p>So basically you have 3 choices for solving this problem. The first (and most obvious is to swap the hard disk in the computer you are trying to install the operating system on for one of equal size or bigger than that on which the original RIPREP image was made.</p>
<p>The second choice is to make a dummy RIPREP image. Find the computer with the smallest hard disk (out of all the computers you want to install the operating system on), start riprep.exe on it (usually found with the collection of RIS utilities on \\servername\reminst). Now as you proceed through each stage of the wizard for making your dummy riprep image keep an eye on the following folder:</p>
<p>\\servername\reminst\Setup\English\Images\dummyimagename\i386\Mirror1</p>
<p>As soon as the file named IMirror.dat appears turn the computer off. You can now use the IMirror.dat file from your dummy image which was made on the smaller hard disk in place of the IMirror.dat file for the image that is causing the problem. You should now be able to install the operating system without the error halting the setup. One other point I would like to make here is that if you simply copy an IMirror.dat file from a random RIPREP image you may have on your server into the image you are having problems with, and this IMirror.dat file was made on a smaller hard disk, you may still encounter problems. This is because the IMirror.dat file contains other information such as the HAL used and OS version.</p>
<p>As you may have guessed, the IMirror.dat file is the file that contains the size of the disk that the image was made on, this brings us to our third choice for solving the problem, editing the IMirror.dat file so that RIS thinks we made the image on a smaller sized hard disk in the first place.</p>
<p>First things first, make a copy of the IMirror.dat file you wish to change and place it somewhere safe. Now open the IMirror.dat file that is causing the problem in your favourite HEX editor. Mine happens to be UltraEdit. According to the following post, the hard drive size is stored in offset C8 - CF:</p>
<p><a href="http://www.mcse.ms/showthread.php?p=6423968#post6423968" target="_blank" rel="nofollow">MCSE.MS Forums</a></p>
<p>Also in the above post are examples of hard disk sizes converted to bytes in little endian format. So, as per the post I edit offset C8 - CF and set the value to that of a 6GB sized hard disk. So:</p>
<p>6 GB =  6 442 450 944 bytes = 00 00 00 01 80 00 00 00<br />
hex = 00 00 00 80 01 00 00 00 hex (little endian)</p>
<p>This is that value I always use. Once you have changed the hex values for the value of the 6GB hard disk at offset C8 - CF, save the IMirror.dat and use RIS to try and install your operating system again. This time it should be successful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2007/09/25/ris-hard-disk-size-problem/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Server 2003 SP2 problems</title>
		<link>http://www.jjclements.co.uk/2007/09/15/windows-2003-server-sp2-problems/</link>
		<comments>http://www.jjclements.co.uk/2007/09/15/windows-2003-server-sp2-problems/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 14:50:24 +0000</pubDate>
		<dc:creator>James Clements</dc:creator>
				<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[autotuninglevel]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[netsh]]></category>

		<guid isPermaLink="false">http://www.jjclements.co.uk/index.php/2007/09/15/windows-2003-server-sp2-problems/</guid>
		<description><![CDATA[After its recent release I installed Service Pack 2 on all computers running Microsoft Windows Server 2003 at work. I encountered a few strange problems. The most noticeable was a problem with all Vista clients. After patching the servers it seemed all Vista clients were incredibly slow at authenticating and generally transferring any form of [...]]]></description>
			<content:encoded><![CDATA[<p>After its recent release I installed Service Pack 2 on all computers running Microsoft Windows Server 2003 at work. I encountered a few strange problems. </p>
<p><span id="more-31"></span></p>
<p>The most noticeable was a problem with all Vista clients. After patching the servers it seemed all Vista clients were incredibly slow at authenticating and generally transferring any form of data between client and server. A quick test with a Windows XP client revealed that browsing a file server was not unbearable like the Vista client, but there was a noticeable difference in waiting for directory listings etc. </p>
<p>Another problem that immediately came to light was the dramatic degradation of performance on terminal servers. Although I could still log onto the terminal server (albeit very slowly), the client was very slow to respond to any changes I made on the server such as typing into a text document and the sudden movement of minimizing different windows etc.</p>
<p>So it seemed I had a very big problem on my hands, luckily I didn't install the Service Pack during the working day. I was stumped as to what was causing the problem, but a quick Google returned some interesting results. The first was this:</p>
<p><a href="http://weblogs.asp.net/wallym/archive/2007/03/27/windows-2003-server-with-sp2-and-vista-problems.aspx" target="_blank" rel="nofollow">Wally McClure's Blog</a></p>
<p>Apparently Vista automatically tunes its network settings to make the most of the available bandwidth. In some scenarios though Windows Vista can fail to connect to the network. To view the current TCP optimisation settings issue the following command in a command prompt:</p>
<p>netsh interface tcp show global</p>
<p>The procedure for fixing the problem with Vista clients seemed easy enough, log onto the Vista clients as an administrator and issue the following commands in a command prompt to disable autotuning:</p>
<p>netsh interface tcp set global rss=disabled<br />
netsh interface tcp set global autotuninglevel=disabled</p>
<p>I have to confess that I never tried the above method to cure the problem of Vista clients experiencing slow data transfer. The reason for this was that I was more concerned with the problem that terminal services users were going to experience and any other problems that Windows XP clients faced (since it was only a colleague and myself that were using Windows Vista). On Wally McClure's Blog was a link to an interesting article on Google Groups:</p>
<p><a href="http://groups.google.com/group/microsoft.public.windows.server.general/browse_thread/thread/fd6450f68aa66be8/85e2561543d0b3e3?lnk=st&#038;q=windows+2003+sp2+slow&#038;rnum=1&#038;hl=en#85e2561543d0b3e3" target="_blank" rel="nofollow">Google Groups - microsoft.public.windows.server.general</a></p>
<p>A post made in the Google Groups article suggested "The fix is to start the Windows Firewall service on the Windows 2K3 SP2 server". After a discussion with a friend and fellow admin it was decided to start the 'Windows Firewall/Internet Connection Sharing (ICS)' service on all Windows 2003 servers. I actually implemented this through group policy on all Windows 2003 file and terminal servers. I also changed the policy setting for 'Windows Firewall: Protect all network connections' to Disabled. So effectively the firewall service is running but not protecting.</p>
<p>After running a gpupdate on the servers everything was fine. Vista clients were able to authenticate and browse for files at speeds prior to those of the SP2 installation and terminal services was responding as it should. I didn't have to disable autotuning on the Vista clients.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jjclements.co.uk/2007/09/15/windows-2003-server-sp2-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
