IIS网站创建失败-对象标识符不代表有效的对象。 (来自HRESULT的异常:0x800710D8)

我编写了一个PowerShell脚本块,用于在Azure虚拟机规模集上创建IIS应用程序池和网站。设置多个实例,而该脚本块并行运行时,出现错误对象标识符不代表有效的对象。 (来自HRESULT的异常:0x800710D8),有人可以帮忙吗?

重置IIS并没有帮助,我还确保创建了应用程序池,并等待5秒以完成该过程,仍然是相同的问题。

这是我在脚本块中写的

导入模块-名称WebAdministration

# get SSL certificate thumbprint to attach
$thumbprint = Get-ChildItem -Path Cert:\LocalMachine\My | where-Object { $_.subject -like $certName } | Select-Object -ExpandProperty Thumbprint

# check the existing app pool 
$apppoolExists = Get-IISAppPool -Name $appPoolName
if (!($apppoolExists.Name -ieq $appPoolName)) {
    # create a new web application pool
    New-WebAppPool -Name $appPoolName -Force
    Start-WebAppPool -Name $appPoolName
    Start-Sleep -Seconds 5
    Write-Host "Application pool : $appPoolName created successfully"
} else {
    Write-Host "App pool $appPoolName already exists"
}
# set user identity with custom account for app pool
Set-ItemProperty IIS:\AppPools\$appPoolName -name processModel -value @{username = $username; password = $password; identitytype = 3 }

# set website path code
------- assume setting path -------

# check existing website
$siteExists = Get-Website -Name $siteName
if (!($siteExists.name -ieq $siteName)) {
    # create a new website
    New-WebSite -Name $siteName -PhysicalPath $physicalPathWebsite -ApplicationPool $appPoolName -Force
    Write-Host "Web site : $siteName created successfully"
} else {
    Write-Host "Website $siteName already exists"
}
# remove http binding
Get-WebBinding -Name $siteName -Protocol http -Port 80 | Remove-WebBinding
Get-WebBinding -Name $siteName -Protocol https -Port 443 | Remove-WebBinding

# add binding to website 
New-WebBinding -Name $siteName -Port $port -Protocol $protocol -HostHeader $CName -Sslflags 1 -Force

# add an SSL certificate to binding
$binding = Get-WebBinding -Name $SiteName -Port $Port -Protocol 'https'
$binding.AddSslCertificate($thumbprint,'my')

# start website
Start-Website -Name $siteName 
Write-Host "website : $siteName started"

Write-Host "IIS website and application pool creation successful"
fengzi3688 回答:IIS网站创建失败-对象标识符不代表有效的对象。 (来自HRESULT的异常:0x800710D8)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3119300.html

大家都在问