api - Update SharePoint Default Alternate Access Mapping Programatically -


i'm enabling https on iis server have sharepoint services 3.0 installed , i'd programatically update default alternate access mappings single web application , central administration instance (both on same machine). here's code have far (powershell), adds mapping https , error when trying remove original one.

here's code:

[void][system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")  $spwebservicecollection = new-object microsoft.sharepoint.administration.spwebservicecollection ([microsoft.sharepoint.administration.spfarm]::local)      foreach ($spwebservice in $spwebservicecollection) {          foreach ($webapplication in $spwebservice.webapplications) {              write-host ('updating {0}' -f $webapplication.name)              foreach ($alternateurl in $webapplication.alternateurls) {                  $incomingurl = [system.uri] $alternateurl.incomingurl                  $newurl = 'https://{0}{1}' -f  $incomingurl.authority, $incomingurl.pathandquery                  $newalturl = new-object microsoft.sharepoint.administration.spalternateurl ($newurl, $alternateurl.urlzone)                  $webapplication.alternateurls.add($newalturl)                  $webapplication.alternateurls.update($true)                  $webapplication.alternateurls.remove($alternateurl) #throws exception                  $webapplication.alternateurls.update($true)            }         }     } 

here error when try remove original:

exception calling "remove" "1" argument(s): "an object in sharepoint administrative framework, "spalternateurlcollection name=sharepoint - 1000 parent=spfarm name=sharepoint_config_8ddd3701-a332-4e79-98e4-fa11c1b6c17c", not deleted because other objects depend on it. update of these dependants point null or different objects , retry operation. dependant objects follows:

spwebapplication name=sharepoint - 1000 parent=spwebservice

however, i'm not sure how exception suggests.

ah... looks trying remove url webservice using...


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -