Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powershell IIS 6.0 Httpredirect

Status
Not open for further replies.

ThundaGlosh

Programmer
Sep 17, 2007
1
US
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()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top