Powershell에서 Start-Website 명령을 실행할 때 "파일을 만들 수 없습니다" 오류가 발생했습니다.
현재 이 파워셸 스크립트를 실행하려고 합니다.
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
중요한 경우 웹사이트를 삭제할 수 있는 다음과 같은 스크립트도 가지고 있습니다.
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"
오류 메시지:
시작-웹 사이트 : 해당 파일이 이미 존재하는 경우 파일을 만들 수 없습니다.
...일반적으로 동일한 IP 주소, 포트에서 이미 실행 중인 사이트와 이를 사용하는 경우 호스트 헤더에서 바인딩 충돌이 발생합니다.
IIS MMC에서 새 사이트 바인딩을 확인한 다음 다른 사이트에서 정확히 동일한 바인딩을 사용하고 있는지 알아보겠습니다.
IIS 구성에 웹 사이트가 없으면 동일한 오류가 발생했습니다.이유는 마지막에 추가적인, 오래된 기록들이었습니다.applicationHost.config. IIS Manager에서 볼 수 있는 것은 없습니다.이 XML 레코드를 제거한 후 문제가 해결되었습니다.
같은 오류로 문제가 생겼습니다.이 문제는 IIS 사이트에 원격으로 웹 바인딩을 추가하려고 할 때 발생하며, 다른 에이전트 컴퓨터에서 Invoke-Command를 사용합니다.
나한테 효과가 있어요 누군가에게도 도움이 될 수도 있어요
$Mutex = New-Object -TypeName System.Threading.Mutex($false, "Global\Mutex")
if ($Mutex.WaitOne(300000)) {
#For example
#$Command = {
#New-WebBinding -name $iis_site_name -Protocol https -HostHeader
#$iis_host_name -Port 443 -SslFlags 1
#}
#Invoke-Command -Command $Command
} else {
Write-Warning "Timed out acquiring mutex!"
}
$Mutex.Dispose()
자세한 오류 추적을 활성화하여 이유를 찾습니다.저 같은 경우에는.mimeType기본 요소를 복제했습니다.
언급URL : https://stackoverflow.com/questions/11162857/cannot-create-a-file-error-when-running-start-website-command-in-powershell
'programing' 카테고리의 다른 글
| 자바스크립트 - 파일 입력 컨트롤에서 파일명을 추출하는 방법 (0) | 2023.10.06 |
|---|---|
| @RunWith 및 @ContextConfiguration으로 주석이 달린 jUnit 테스트에서 Spring 컨텍스트에 액세스하는 방법은 무엇입니까? (0) | 2023.10.06 |
| 각진 안전하지 않은 링크 (0) | 2023.10.06 |
| Oracle PL/SQL의 테이블 변수? (0) | 2023.10.01 |
| Vulkan: vk*CreateInfo structs에서 sType의 요점은 무엇입니까? (0) | 2023.10.01 |