운영체제

Powershell IIS 속성 변경

warpmemory 2020. 3. 5. 19:33
1
2
3
4
5
6
7
8
9
10
11
12
13
import-module webadministration
$rows = ls IIS:\Sites |select Name
foreach ($row in $rows){
    $site_name = $row.Name
    if (($site_name -ne "Default FTP Site") -and ($site_name -ne "Default Web Site") -and !($site_name -match "_ftp") ){
        $webknight_path = Get-WebConfigurationProperty -filter //isapiFilters -PSPath "iis:\sites\$site_name" -name Collection[name="WebKnight"] |select path
        echo $row.Name
        echo $webknight_path
        $new_webknight_path = $webknight_path.Path -replace "F:", "D:"
        remove-WebConfigurationProperty -filter /system.webServer/isapiFilters -PSPath 'IIS:\' -name Collection[name="WebKnight"] -Location $row.Name
        Add-WebConfiguration -filter /system.webServer/isapiFilters -PSPath "IIS:\" -Value @{name="WebKnight";path=$new_webknight_path} -Location $row.Name
    }
}
cs