ThundaGlosh
Programmer
I am running into an issue while using powershell to configure my IIS server for a web page update. I set the httpredirect before I copy over the files for the update. The problem is when you reference the httpredirect property, it creates a property key in the metabase. You then cannot reset the virtual directory to read from its default directory "inetpub\ files" because the httpredirect key is still there. Setting the key to null string dosent work. I dont want to open the metabase for editing that is way to risky. Does anybody have code to remove a property from the a virtual directory? Here is my code
Write-Host "Re-Directing Virtual Directory "$VirDirName" on "$sIISName
add-content $logfile "Re-Directing Virtual Directory $VirDirName on $sIISName"
get-date|add-content $logfile
Write-Host ""
$oDE = New-Object System.DirectoryServices.DirectoryEntry("IIS:\\"+$sIISName+"\W3SVC\1\Root\"+$virdirname)
$ode.httpredirect.set_value("$oVirDir.setinfo()
#========================================Copying over updated files===============================================
$ErrMsg="An Unexpected Error has Occurred."
Write-Host "Copying Updated files to "+$sIISName ". Please wait."
add-content $logfile "Copying Updated files to $sIISName. Please wait."
Write-Host
Copy-Item $sSrcPath\* $sdestpath\$virDirName -recurse -force
Write-Host "Copy Complete"
add-content $logfile "Copy Complete"
get-date|add-content $logfile
Write-Host
#=======================================Resetting the Redirect ===================================================
$ode.httpredirect.set_value("")
$oVirDir.setinfo()
Write-Host "Re-Directing Virtual Directory "$VirDirName" on "$sIISName
add-content $logfile "Re-Directing Virtual Directory $VirDirName on $sIISName"
get-date|add-content $logfile
Write-Host ""
$oDE = New-Object System.DirectoryServices.DirectoryEntry("IIS:\\"+$sIISName+"\W3SVC\1\Root\"+$virdirname)
$ode.httpredirect.set_value("$oVirDir.setinfo()
#========================================Copying over updated files===============================================
$ErrMsg="An Unexpected Error has Occurred."
Write-Host "Copying Updated files to "+$sIISName ". Please wait."
add-content $logfile "Copying Updated files to $sIISName. Please wait."
Write-Host
Copy-Item $sSrcPath\* $sdestpath\$virDirName -recurse -force
Write-Host "Copy Complete"
add-content $logfile "Copy Complete"
get-date|add-content $logfile
Write-Host
#=======================================Resetting the Redirect ===================================================
$ode.httpredirect.set_value("")
$oVirDir.setinfo()