Archive for March, 2010

Deleting old “Internet Newsgroups” Public Folder which prevents Exchange 2007 to be uninstalled

March 31, 2010

There was migration from Exchange 2003 to Exchange 2007. After some time when Exchange 2010 appeared i’ve migrated half of my enviroment to Exchange 2010. After that i moved all mailboxes to the new exchange server. After that it came time for uninstalling the old Exchange 2007 server. Here came the fuirst problem. I had to move all replications of public folders to other exchange servers. It’s not a heavy task and there is powershell script:

.\MoveAllReplicas.ps1 -Server ExchOld2007  -NewServer Exch2010New.

After that i’ve need to remove all public folders on the old Exchange 2007 server.

You can stop replication of Public folders totally that way:

Get-PublicFolder -server ExchOld2007  “\” -Recurse -ResultSize:Unlimited | Remove-PublicFolder -server ExchOld2007 -Recurse -ErrorAction:SilentlyContinue

When i try uninstalling Exchange Server 2007 again i faced the following new error:

Uninstall cannot proceed. Database ‘Public Folder Database’: The public folder database specified contains folder replicas. Before deleting the public folder database, remove the folders or move the replicas to another public folder database.

After that i went to the pulic folders GUI console it appears Internet Newsgroups Public Folder. When i tried to delet it there is another error:

Microsoft Exchange Error
Action ‘Remove’ could not be performed on object ‘Internet Newsgroups’.

Internet Newsgroups
Cannot delete the object ‘\Internet Newsgroups’. Please make sure that you specified the correct identity

and that you have the correct permissions to delete it.

MapiExceptionPartialCompletion: Unable to delete folder. (hr=0x40680, ec=0)
Diagnostic context:

So the solution here is deleting that particular folder from ADSIEDIT.MSC

1. Open Adsiedit.msc from run command
2. Navigate to your configuration container

3. Expand to services, Microsoft Exchange, your organization name, administrative groups,Exchange Administrative Group, servers, locate your MailBox Server, expand it and then locate information store.
4. Locate particular storage group where is public folder store. On the right pane, delete the public folder store (storage group).

After that uninstallation continue fluently.

Install Windows Server 2008as backup feature on Server Core

March 19, 2010

What do you need to backup Server 2008 Core computer ? Yes there is a feature which makes VSS backups.

start /w ocsetup WindowsServerBackup – this installs windows server backup feature.

After that you can start backing up using cmd tool called wbadmin. Here is one example backing up D: to shared

network folder:

wbadmin start backup -backuptarget:\\Server02\BackupShare  -include:d:

Vbscript creating many folders

March 9, 2010

Very good vbscript if you need to create folders. In my cause i had to create for example in Archive folder many little subfolders from 001,002,..010,011…099,100 to 300.

ParentFolder = “C:\Archive”
set objShell = CreateObject(“Shell.Application”)
set objFolder = objShell.NameSpace(ParentFolder)
FOR i=1 to 9
objFolder.NewFolder “00”+CStr(i)
FOR i=10 to 99
objFolder.NewFolder “0”+CStr(i)
FOR i=100 to 300
objFolder.NewFolder CStr(i)

How to remove files from folder with VBScript

March 9, 2010

Here is the script. It is usefull for example if you need to remove old backup files from a folder or some old log files. The only thing is to put it to task schedule. Here is the script:

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“C:\inetpub\logs\logfiles\W3SVC3”)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete


So some explanations

Set Fso = CreateObject(“Scripting.FileSystemObject”) //create file system objct

Set Directory = Fso.GetFolder(“some path”) //this is the actual folder which will be searched for files

For Each Modified in Files //this is the actual loop for every file in the directory

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete //here you should set how log the files will be keeped. 30 in this example means if  the files is more than 30 days old then delete it. The funktion compares every file with today date and in this cause if today is 30 days more than date of some file it deletes it.

After that make a simple task schedule with cscript <some filename.vbs>. This will run script in command line.

Here there is some slightly different modification of the script. If somebody wonders how the script could be modified in that manner, that it can remove old files (or data) from subfolder beneath some root folder. Here is the modified script.

Let’s say we have the followind scenario. We have Microsoft SQL server 2008 and a maintenance plan which takes care of backups. All backups have been made in a folder called D:\SQL Backups.

In addition to the above script i will introduce a variable  Dim Subdirectory. In that cause we have Directory and Subdirectory variables. The difference is the line Set SubDirectory = Directory.Subfolders. Whith that line Subdirectory variable gets all subdirectories underneath. f1 is some kind of subsidiary variable represent object to access to every file in every subdirectory.

Dim Fso

Dim Directory

Dim Modified

Dim Files

Dim SubDirectory

Dim f1

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“D:\SQL Backups”)

Set SubDirectory = Directory.Subfolders

For Each f1 in Subdirectory

Set Files = f1.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 3 Then Modified.Delete