Remove ssl binding

31/10/2012 17:20

There are only code examples here for different access to objects. This code itself doesn't have funcionality (no sense here).

Import-Module WebAdministration
Remove-Item -path "IIS:\SslBindings\!443" #detach certificate from the site

//access iis structure

dir IIS:\sites\Chamdev7.Secure.fln.Local

(Get-ItemProperty IIS:\Sites\Chamdev7.Secure.fln.Local -Name bindings).Collection

#stopped site with the same port set
get-childitem IIS:\sites|where-object {$_.State -eq  "Stopped"}|% {$_.Bindings.Collection}
get-childitem IIS:\sites|where-object {$_.State -eq  "Stopped"}|% {$_.Bindings.Collection}|% {$_.bindinginformation -match ":443"}
$s=get-childitem "IIS:\sites"|where-object {$_.Name -eq "Default Web Site"} #able to Start(), Stop()
$s.bindings.Collection|%{$_.bindingInformation -match ":443"} #collection false, false, false, true

//certificates access cert: drive

set-location cert:\LocalMachine\Root
$c=get-childitem cert:\LocalMachine\Root |where-object {$_.Subject -match "Secure.fln.Local"}|remove-item
//remove-item is not available in PS 2.0
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
$site = $serverManager.Sites | where { $_.Name -eq $siteName }
#way to remove binding, no permissions using IIS: drive
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
$site = $serverManager.Sites | where { $_.Name -eq ""}