現在、このpowershellスクリプトを実行しようとしています:
Param (
$websiteName,
$physicalPath
)
import-module WebAdministration
$website = get-website | where-object { $_.name -eq "$websiteName" }
if($website -eq $null){
New-webapppool -Name "$websiteName"
Set-WebConfiguration -filter "/system.applicationHost/applicationPools/add[@name='$websiteName']" -PSPath IIS:\ -value (@{managedRuntimeVersion="v4.0"})
New-website -Name "$websiteName" -PhysicalPath "$physicalPath" -ApplicationPool "$websiteName"
start-website "$websiteName"
}
次のコマンドを使用してスクリプトを実行します。
& .\InstallWebsite.ps1 -websiteName "MyWebsite" -physicalPath "C:\TEST\MyWebsite"
if ステートメント内の最後のコマンドを除いて、すべて正常に動作します。
start-website "$websiteName"
そのコマンドを実行すると、次のエラーが表示されますが、トラブルシューティングを成功させることができませんでした。
Start-Website : Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)
At line:1 char:14
+ start-website <<<< "MyWebsite"
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
重要な場合は、Web サイトを削除する次のスクリプトもあります。
Param (
$websiteName,
$appPoolName
)
import-module WebAdministration
$website = get-website | where-object { $_.name -eq "$websiteName" }
if($website -ne $null){
remove-website -Name "$websiteName"
remove-webapppool -Name "$websiteName"
}
次のコマンドで実行します。
& .\UninstallWebsite.ps1 -websiteName "MyWebsite" -appPoolname "MyWebsite"