Mittwoch, 30. Dezember 2009

Get the Service Tag from Dell computers

Get-WmiObject win32_SystemEnclosure | select serialnumber

WSUS automated Cleanup

This script performs the cleanup tasks done by the WSUS cleanup wizard. Because it is a script, it can be automated (for example, via the Windows Task Scheduler). It also provides extended support for computer cleanup, allowing one to specify the number of days of not hearing from the computer before cleanup (default is 30 days), and to optionally skip deletion of computers that are still in Active Directory Directory Services (to avoid accidently removing computers that are still around but having trouble contacting the server). We recommend also performing SQL defragmentation sample script as part of WSUS cleanup.
Thx to ScriptingGuys.

| out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$cleanupScope.DeclineSupersededUpdates = $true
$cleanupScope.DeclineExpiredUpdates = $true
$cleanupScope.CleanupObsoleteUpdates = $true
$cleanupScope.CompressUpdates = $true
#$cleanupScope.CleanupObsoleteComputers = $true
$cleanupScope.CleanupUnneededContentFiles = $true
$cleanupManager = $wsus.GetCleanupManager();

Exchange Autodiscover Song

You have to hear the Autodiscover Song :)



There is no other
Way to decide
Where your mailbox is stored

Your sister and brother
Exchange Admin and mother
Will be proud if you do

You may be tempted to wing it
Use a hardcoded link submit it
But performance will suffer
When you’re left to your druthers
Should have Autodiscovered
Then all would be well

Call it once for each mailbox of interest
Pair the link and mailbox for each request
If you encounter errors
Refresh once again
For more information search M-S-D-N for


Exchange won't exist in a bubble
If you think that it will you're in trouble
Add a site, one or two
And your perf will be through
Unless you step up and decide that your app will just...


Just AutoDiscover for me.
It’s just plain XML

Montag, 28. Dezember 2009

ISA Server 2006 - PPTP / RRAS Probleme mit Update KB956570

How to disable this update
If you encounter problems after you install this update, you can disable this update.

At the command prompt, type the following command:
cscript KB956570.vbs
Restart the computer that is running ISA Server.


Const SE_VPS_GUID = "{143F5698-103B-12D4-FF34-1F34767DEabc}"
Const SE_VPS_NAME = "BindRandomizationCount"
Const SE_VPS_VALUE = 0

Sub SetValue()

' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")

'Declare the other objects needed.
Dim array ' An FPCArray object
Dim VendorSets ' An FPCVendorParametersSets collection
Dim VendorSet ' An FPCVendorParametersSet object

' Get references to the array object
' and the network rules collection.
Set array = root.GetContainingArray
Set VendorSets = array.VendorParametersSets

On Error Resume Next
Set VendorSet = VendorSets.Item( SE_VPS_GUID )

If Err.Number <> 0 Then

' Add the item
Set VendorSet = VendorSets.Add( SE_VPS_GUID )
WScript.Echo "New VendorSet added... " & VendorSet.Name

WScript.Echo "Existing VendorSet found... value- " & VendorSet.Value(SE_VPS_NAME)
End If

if VendorSet.Value(SE_VPS_NAME) <> SE_VPS_VALUE Then


If Err.Number <> 0 Then
VendorSets.Save false, true

If Err.Number = 0 Then
WScript.Echo "Done with " & SE_VPS_NAME & ", saved!"
End If
End If
WScript.Echo "Done with " & SE_VPS_NAME & ", no change!"
End If

End Sub

Sub CheckError()

If Err.Number <> 0 Then
WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & " " & Err.Description
End If

End Sub


Samstag, 26. Dezember 2009

Add Feature Microsoft .NET Framework 3.5. during Exchange 2010 Install

While installing Exchange 2010, you may get the following error message:

"You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5."

Cause Windows 2008 R2 ships with .Net 3.5.1, you just need to enable the feature within the Server Manager -> Features:

Service Net. TCP Port Sharing / Exchange 2010

During the Readiness Checks you get the following error:

The start mode for the Net. TCP Port Sharing service must be set to Automatic before Setup can continue”.

Open Powershell:

Set-Service NetTcpPortSharing -StartupType Automatic

Samstag, 19. Dezember 2009

Get the Names of Mailboxes That are Quota+

get-MailboxStatistics | where {"IssueWarning","ProhibitSend","MailboxDisabled" -contains $_.StorageLimitStatus} | format-Table DisplayName,TotalItemSize

ISA 2006 Backup Script

' based on:

' Usage: cscript /nologo ISABackup.vbs strBackupShare

' - strBackupShare (String) UNC Path of the Share where the Backup will be stored

' Should the Script send any notification E-Mails
Const blSendMails = true

' The E-Mail Server to use when sending Backup notifications
Const strEmailServer = server.local"

' The E-Mail Address from which the Mails will appear to come from
Const strEmailFromAddr = "postmaster@domain.tld"

' The Recipients od the Backup notifications. Multiple Recipients are to be separated with a semicolon.
Const strEmailRecipients = "info@domain.tld"

Private Sub SendEmail (ByVal strFrom, strRecipient, strSubject, strText, strServer, isUrgent)

Dim objEmail

Set objEmail = CreateObject("CDO.Message")

objEmail.From = strFrom
objEmail.To = strRecipient
objEmail.Subject = strSubject
objEmail.Textbody = strText

If isUrgent Then

With objEmail.Fields

.Item("urn:schemas:mailheader:X-MSMail-Priority") = "High"
.Item("urn:schemas:mailheader:X-Priority") = 2
.Item("urn:schemas:httpmail:importance") = 2

End With

End If

With objEmail.Configuration.Fields

.Item("") = 2
.Item("") = strServer
.Item("") = 25

End With


End Sub

Function LogConsoleOutput (ByVal strText)

strText = GetTimeString & ": " & strText

objEventLogFile.WriteLine strText

strConsoleOutput = strConsoleOutput & strText & vbCrLf

WScript.echo strText

End Function

Function AppendZeroToTen (byVal Input)

If (Input < 10) Then
AppendZeroToTen = "0" & Input
AppendZeroToTen = Input
End If

End Function

Function GetDateString

Dim dtmCurrentDate, dtmDay, dtmMonth, dtmYear

dtmCurrentDate = date()

dtmDay = DatePart("d", dtmCurrentDate)
dtmMonth = DatePart("m", dtmCurrentDate)
dtmYear = DatePart("yyyy", dtmCurrentDate)

GetDateString = AppendZeroToTen(dtmDay) & "." &_
AppendZeroToTen(dtmMonth) & "." &_

End Function

Function GetTimeString

Dim dtmCurrentTime, dtmHour, dtmMinute, dtmSecond

dtmCurrentTime = time()

dtmHour = DatePart("h", dtmCurrentTime)
dtmMinute = DatePart("n", dtmCurrentTime)
dtmSecond = DatePart("s", dtmCurrentTime)

GetTimeString = AppendZeroToTen(dtmHour) & ":" &_
AppendZeroToTen(dtmMinute) & ":" &_

End Function

Function DeleteIfExists (byVal strFile)

if objFSO.FileExists(strFile) Then


End If

End Function

Dim objFSO : set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objNetWork : set objNetWork = CreateObject("WScript.Network")
Dim strBackupShare : strBackupShare = WScript.Arguments(0)
Dim objXMLDOM : set objXMLDOM = CreateObject("Msxml2.DOMDocument")
Dim objFPC : set objFPC = WScript.CreateObject("fpc.Root")
Dim objISAArray : set objISAArray = objFPC.GetContainingArray
Dim strFileName
Dim blErrorsOccurred : blErrorsOccurred = false
Dim strHostName : strHostName = objNetWork.ComputerName
Dim strEmailSubject : strEmailSubject = strHostName & ": Backup am " & GetDateString & " durchgeführt"
Dim strConsoleOutput

strScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
strEventLogFile = strScriptPath & "logs\" & strHostName & "-D" & Replace(GetDateString,".","") & "-T" & Replace(GetTimeString,":","") & ".txt"

DeleteIfExists (strEventLogFile)
set objEventLogFile = objFSO.CreateTextFile(strEventLogFile, CopyOverwrite)

LogConsoleOutput "Starting Backup"
LogConsoleOutput "Logging to Text File " & strEventLogFile

strFileName = strBackupShare & "\" & strHostName & "-D" & Replace(GetDateString,".","") & "-T" & Replace(GetTimeString,":","") & ".xml"

LogConsoleOutput "Exporting Configuration"

objISAArray.Export objXMLDOM, 0

LogConsoleOutput "Saving exported Configuration to File " & strFileName

LogConsoleOutput "Backup Finished"

If blSendMails Then

Call SendEmail (strEmailFromAddr, strEmailRecipients, strEmailSubject, strConsoleOutput, strEmailServer, blErrorsOccurred)

End If


Mittwoch, 16. Dezember 2009

Delete Files older then X Days Powershell

1. set-executionpolicy RemoteSigned
2. within a batch -> powershell -command "& 'SCRIPTNAME.ps1' " for Scheduled Task.

Function GetOldFile
$Days = "2"
$TargetFolder = "C:\pathtofolder"
if (Test-Path $TargetFolder)
$Now = Get-Date
$LastWrite = $Now.AddDays(-$days)
$Files = get-childitem $TargetFolder -include *.log -recurse |Where {$_.LastWriteTime -le "$LastWrite"}
foreach ($File in $Files)
{write-host "Deleting file $File" -foregroundcolor "Red"; Remove-Item $File | out-null}
{Write-Host "Folder $TargetFolder doesnt exist! Recheck the folder path!"}

Saved Queries to Query Locked Out Accounts

You can use the Saved Queries feature of Windows Server 2003 to query Active Directory for any locked-out accounts. Just open the Active Directory Users and Computers console, right-click on Saved Queries in the console tree and select New --> Query. Type a name and description for the query, specify a query root (where in your namespace your query begins searching), and click the Define Query button. Since there's no default option for finding locked-out accounts in the Common Queries box, select Custom Search instead to open the Find Custom Search box. Then select the Advanced tab and enter the following LDAP string in the Enter LDAP Query textbox:


Click OK twice to create and run the saved query.
The string works on Windows Server 2003 SP1.
Update: Here's another LDAP query that finds all locked out accounts:


Dienstag, 15. Dezember 2009

Restart mgmt-vmware ESX 3.x

How to restart mgmt-vmware on a VMware ESX 3.x:

SSH to the Vmware ESX


service mgmt-vmware restart

or /sbin/service mgmt-vmware restart

This would be the solution if you can’t connect to the box using VMware Infrastructure Client, like if you get an error saying:
Error Connecting
VMware Infrastructure Client could not establish the initial connection with the server ““.
Details: The server took too long to respond.