Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to backup IIS6 with PowerShell, I have found the method I am after in WMI's IISComputer.BackupWithPassword however when I try to execute it with the following PowerShell:

$IISComputer = Get-WmiObject -Namespace "root/MicrosoftIISv2" -Class "IISComputer"
$IISComputer.BackupWithPassword("D:\Backup\Wednesday\", 1, 6, "QUESTTSTS")

I am presented with:

Exception calling "BackupWithPassword" : "Win32: The parameter is incorrect.

At line:1 char:32

Having tried various combinations of brackets, quotes, flags, etc. I haven't really got any further with figuring out why this dosn't work.

Any thoughts on getting this to work, I am aware of iisback.vbs and other mechanisms for doing this. This is as much an excercise as a practicable solution to a problem.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I figured this out eventually, the following code works:

$HIGHEST_VERSION = 9999
$BACKUP_OVERWRITE = 1
$BACKUP_FORCE = 4
$BACKUP_SAVE_FIRST = 2
$Flags = $BACKUP_OVERWRITE -bor $BACKUP_FORCE
$Password = "WhiskyW4i5kyWh1sky"
$IISComputer = Get-WmiObject -Namespace "root/MicrosoftIISv2" -Class "IISComputer"
$result = $IISComputer.BackupWithPassword("ScriptedBackup", $HIGHEST_VERSION, $BACKUP_OVERWRITE, $Password)

I have tried to emulate the variable names from the TechNet article IisComputer.BackupWithPassword to allow for comparisons. The backup is created in %SYSTEMROOT%\system32\inetsrv\MetaBack named ScriptedBackup.MD9999 and ScriptedBackup.SC9999 these two files can be copied across to another location or backed up by your backup software.

share|improve this answer

I don't have IIS6 handy right now. Check this: http://www.vbsedit.com/scripts/iis/iis6/admin/scr_504.asp

It doesn't appear that you can "mask" the values like you've done with 4+2=6.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.