小编Jar*_*gin的帖子

在Powershell中运行Start-Website命令时出现"无法创建文件"错误

目前我正在尝试运行这个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"
}
Run Code Online (Sandbox Code Playgroud)

我使用以下命令来运行脚本:

& .\InstallWebsite.ps1 -websiteName "MyWebsite" -physicalPath "C:\TEST\MyWebsite"
Run Code Online (Sandbox Code Playgroud)

一切正常,除了if语句中的最后一个命令:

start-website "$websiteName"
Run Code Online (Sandbox Code Playgroud)

当该命令运行时,我收到以下错误,我无法成功排除故障:

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], …
Run Code Online (Sandbox Code Playgroud)

powershell iis-7

38
推荐指数
1
解决办法
2万
查看次数

如何确定是否在带有Powershell的IIS7中安装了网站?

我是powershell的新手,我正在尝试自动删除先前版本的网站,并添加新版本作为TFS 2010构建模板(Windows Workflow 4.0)的一部分.是否可以通过PowerShell查看IIS7中是否存在网站或Web应用程序池?我试过运行以下命令:

import-module WebAdministration
Get-Website -Name "Default Web Site"
Run Code Online (Sandbox Code Playgroud)

输出列出了盒子上安装的所有网站,而不仅仅是默认网站.

Name             ID   State      Physical Path                  Bindings
-------------------------------------------------------------------------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:
                                                                net.tcp 808:*
                                                                net.pipe *
                                                                net.msmq localhost
                                                                msmq.formatname localhost 
MyWebsite1       2    Started    C:\inetpub\MyWebsite1          http *:80:mywebsite1.com
MyWebsite2       3    Started    C:\inetpub\MyWebsite2          http *:80:mywebsite2.com
Run Code Online (Sandbox Code Playgroud)

如果我尝试运行没有"-Name"参数的命令,结果完全相同.

powershell iis-7 team-build tfs2010

17
推荐指数
2
解决办法
2万
查看次数

标签 统计

iis-7 ×2

powershell ×2

team-build ×1

tfs2010 ×1