Powershell: Quick script to email DST status
Posted: March 19, 2007 Filed under: SBS Leave a comment »Described by some as "another Y2K", DST in North America started 3 weeks earlier. Unfortunately, I never got to post this in timefor the changeover, but DST will end 1 week later, so we’re not done testing.
Here’s a Powershell script that gets DST status and mails it to the address specified in the command line. It’s great boilerplate code if you need to send a quick status email and much much better than the old way with NT CMD, Blat and VBScript.
# Send-DSTStatus # # Get current time and DST status of specified computer and email to specified user # For use in supporting North American DST changes # # D. Moisan 2/23/2007 # param([string]$computer, [string]$email) # # Parameters (Required): # # -computer <computer to scan for status> # -email <email address> if ($email -eq "") { write-host "Usage:" write-host write-host "send-DSTStatus [-computer <computer>] -email <somebody@somewhere.com>" write-host write-host "`t-computer defaults to local machine if not specified" write-host exit } # # Set up email sender address and server name # $sender = "Administrator@satvonline.org" # Change as needed $mailservername = "salemtv.satv.loc" # Change to your SMTP server's address $mailserver = new-object system.net.mail.smtpClient $mailserver.Host = $mailservername $mailmessage = new-object system.net.mail.mailmessage($sender,$email) # If -computer parameter not specified, use localhost if ($computer -eq "") { $computer = $Env:Computername } # Get WMI Objects $wmios = get-wmiobject "Win32_OperatingSystem" -computer $computer $wmisys = get-wmiobject "Win32_ComputerSystem" -computer $computer # Compose message $maildate = get-date $mailmessage.Subject = "DST Status Report for $computer on $maildate" $mailmessage.Sender = $sender $messagetext = $mailmessage.Subject + "`n`n" $messagetext += "Local Time for $computer : " + $wmios.ConverttoDateTime($wmios.LocalDateTime) + "`n`n" $DSTEnabled = $wmisys.EnableDaylightSavingsTime $DSTInEffect = $wmisys.DaylightInEffect $TZOffset = $wmisys.CurrentTimeZone if ($DSTEnabled) { $messagetext += "DST is ENABLED`n" } else { # We can't tell if Windows 2000 clients have DST implemented since # the WMI property EnableDaylightSavingsTime is not supported there # so if the property is null (as is the case in 2000), we skip reporting # DST enabled. IF it is False (as in an XP/2003 client with DST turned off), # we report that. if ($DSTEnabled -eq $False) { $messagetext += "DST is NOT ENABLED`n" } } if ($DSTInEffect) { $messagetext += "DST is IN EFFECT`n" } else { $messagetext += "DST is NOT IN EFFECT`n" } $messagetext += "Current timezone offset: $TZOffset `n" $messagetext += "`n`n" # Send mail and report it on the console $mailmessage.Body = $messagetext write-host "From: $sender" write-host write-host "To: $email" write-host write-host $messagetext $mailserver.Send($mailmessage)
Wow, the regression testing for Windows Server 2003 SP2 is *really* thorough!
Posted: March 19, 2007 Filed under: SBS Leave a comment »I saw this KB, Windows Server 2003 Service Pack 2 application compatibility, and noted this program tested:
Vendor Application name Version
3D Realms Duke Nukem 3D 1
*snort!*
Gee, do you think Duke Nukem Forever will work on Longhorn Server?
Windows Server 2003 SP2 Quirk: Exchange doesn’t start
Posted: March 15, 2007 Filed under: SBS Leave a comment »Event Source: DCOM
Event ID: 10010
Date: 3/14/2007
Time: 9:48:51 PM
Computer: [...]
Description:
The server {9DA0E106-86CE-11D1-8699-00C04FB98036} did not register with DCOM within the required timeout.
Event Source: Service Control Manager
Event ID: 7024
Date: 3/14/2007
Time: 9:48:56 PM
Computer: [...]
Description:
The Microsoft Exchange Information Store service terminated with service-specific error 2147500037 (0×80004005).