[英]list redirect destinations (URL) IIS sites
I have several redirect sites configured in IIS 8.5, and I want to list them all. 我在IIS 8.5中配置了几个重定向站点,我想列出所有这些站点。 I've tried:
我试过了:
.\appcmd.exe list site * -section:system.webServer/httpRedirect
but wildcards are not working fine with appcmd
. 但是通配符在
appcmd
无法正常工作。 I also tried from the WebAdministration
module: 我也尝试过
WebAdministration
模块:
Get-WebConfiguration system.webServer/httpRedirect * | Get-Member destination
but this is also not delivering what I need... which is a list with 2 columns for site & destination 但这也没有提供我需要的东西......这是一个包含2列网站和目的地的列表
This snippet will give you the sitenames and httpredirect destinations : 此代码段将为您提供网站名称和httpredirect目标:
Get-Website | select name,@{name='destination';e={(Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name "destination" -PSPath "IIS:\Sites\$($_.name)").value}}
For fetching just the destinations: 仅用于获取目的地:
(Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name "destination" -PSPath 'IIS:\Sites\*').value
You can refer to below function to address this issue. 您可以参考以下功能来解决此问题。
Function Get-IISRedirectURLs {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$false)][String]$SiteName
)
If ([String]::IsNullOrEmpty($SiteName)) {
Get-Website | ForEach-Object {
$SiteName = $_.Name
$prop = Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name 'destination' -PSPath "IIS:\Sites\$SiteName"
Write-Host "$SiteName`t$($prop.value)"
}
} Else {
$prop = Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name 'destination' -PSPath "IIS:\Sites\$SiteName"
Write-Host "$SiteName`t$($prop.value)"
}
}
For the complete sample archive, please download from How to list redirect destination URLs of IIS sites by PowerShell 有关完整的示例存档,请从如何列出PowerShell重定向IIS站点的目标URL进行下载
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.