Archive for the ‘Windows things’ Category
Retrieving Missing WMI classes
When missing WMI classes in the namespaces you can take ages getting something to work.
However you can easly regenerate the WMI classes that should be there in the first place using the command
wmiadap /F
I’ve been using it in windows 2003 and it works like a charm!
EX2007 Queue monitoring
Here is the same Queue monitoring script, but then written for exchange 2007.
##
# Exchange queue monitoring for exchange 2007
# Written by Marcel Stangenberger
#
# Created on 27/10/2009
# Version 1.0
##$queuecount = (get-queue | where {$_.MessageCount -gt “20″})
$queueview = (get-queue)
$messageview = (get-queue | where {$_.MessageCount -gt “20″} | get-message)
$redalert = “red ” + (get-date)
$greenalert = “green ” + (get-date)
$tmppath = “C:\Program Files (x86)\Quest Software\Big Brother\BBNT\tmp\queue”
$logpath = “C:\Program Files (x86)\Quest Software\Big Brother\BBNT\Logs\queue”if ( test-path $tmppath )
{
remove-item $tmppath
}if ( $queuecount -eq $null )
{
$greenalert | out-file -encoding ASCII $tmppath
$queueview | out-file -encoding ASCII $tmppath -append
$messageview | out-file -encoding ASCII $tmppath -append
}
Else
{
$redalert | out-file -encoding ASCII $tmppath
$queueview | out-file -encoding ASCII $tmppath -append
$messageview | out-file -encoding ASCII $tmppath -append
}if ( test-path $logpath )
{
remove-item $logpath
}move-item $tmppath $logpath
EX2003 Queue monitoring with powershell
I’m a big fan of powershell. Now for a customer we’re hosting a windows 2003 server running exchange 2003. Since we use BigBrother as a monitoring tool we don’t have all the luxuries that more sophisticated monitoring tools have. So i’ve written a little script that does queue monitoring for you.
##
# Exchange queue monitoring for exchange 2003
# Written by Marcel Stangenberger
#
# Created on 27/10/2009
# Version 1.0
##$queuecount = ((Get-WmiObject -class Exchange_SMTPQueue -Namespace ROOT\MicrosoftExchangev2 |select-object LinkName,MessageCount | where {$_.MessageCount -gt “9″}).count)
$queueview = (Get-WmiObject -class Exchange_SMTPQueue -Namespace ROOT\MicrosoftExchangev2 |select-object LinkName,MessageCount,Size)
$redalert = “red ” + (get-date)
$greenalert = “green ” + (get-date)
$tmppath = “C:\Program Files\Quest Software\Big Brother\BBNT\tmp\queue”
$logpath = “C:\Program Files\Quest Software\Big Brother\BBNT\Logs\queue”if ( test-path $tmppath )
{
remove-item $tmppath
}if ( $queuecount -eq $null )
{
$greenalert | out-file -encoding ASCII $tmppath
$queueview | out-file -encoding ASCII $tmppath -append
}
Else
{
$redalert | out-file -encoding ASCII $tmppath
$queueview | out-file -encoding ASCII $tmppath -append
}if ( test-path $logpath )
{
remove-item $logpath
}move-item $tmppath $logpath
Using a NTP server with Windows 2008
In windows 2003, using a NTP source for time sync a bit of a bother, you had to set it up manually, reset the services and then pray that it would work :
- net time /setsntp:”ntp.xs4all.nl”
- w32tm /query /peers
- net stop w32time
- net start w32time
- w32tm /resync
- w32tm /query /peers
- open up regedit, go to HLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProvider\NtpClient
- locate the SpecialPollInterval DWORD value. Change this to Decimal 43200 (Hex 0000a8c0)
- net stop w32time
- net start w32time
- w32tm /resync
But now, in windows 2008 this entire piece can be replaced by a oneliner :
w32tm /config /manualpeerlist:”ntp.xs4all.nl”