public/http/urlacl/Remove-UrlAcl.ps1
#Requires -RunAsAdministrator function Remove-UrlAcl { <# .SYNOPSIS Removes a urlacl entry for the given url .DESCRIPTION Removes a urlacl entry for the given url or writes an error if the URL reservation is not found. .EXAMPLE PS C:\> Remove-UrlAcl -Url https://+:443/ Removes the URL reservation for the given URL if it exists. .EXAMPLE PS C:\> $user = whoami; Get-UrlAcl | Where-Object { $_.Users.ContainsKey($user) } | Remove-UrlAcl Gets all URL reservations where the current user is included in the list of users under that urlacl reservation and removes them. #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact="High")] param ( # Specifies the url to filter on. Example: http://+:80/MyUri, http://www.contoso.com:80/MyUri # Note: Wildcards are not supported [Parameter(ParameterSetName='UrlFilter', ValueFromPipelineByPropertyName)] [string] $Url ) process { $command = "netsh.exe http delete urlacl url=$Url" Write-Verbose "Executing the command '$command'" if ($PSCmdlet.ShouldProcess((hostname), $command)) { $output = Invoke-Expression -Command $command $success = $LASTEXITCODE -eq 0 if ($success) { Write-Information $output } else { $output = [string]::Join("`r`n", $output).Trim() Write-Error "Error: $output" } } } } |