Pol*_*ase 2 powershell iis-7 powershell-2.0
我想在Windows 2008 R2上部署Web应用程序.我知道单独的PowerShell命令可以执行各种任务.但我想把它放到一个很好的PowerShell脚本中.
我只需要语法,请你帮我做下面的动作:
测试C:\Inetpub\MyWebsite
文件夹是否存在,如果不存在,则创建它.
在IIS7中测试是否MyWebsite
存在,如果没有创建它(我知道如何Import-Module WebAdministration
调用New-WebSite
)
现在复杂的部分.我从Visual Studio 2010准备的软件包中部署了一个Web站点.VS提供了一个.cmd
文件,我只需要在DOS提示符下执行它.这意味着我必须离开PS控制台,打开DOS控制台来运行该cmd文件.是否可以.cmd
从PowerShell控制台中运行文件?
回答你的问题:
Import-Module WebAdministration
# Check for physical path
$sitePath = "c:\inetpub\MyWebsite"
if (-not (Test-Path -path $sitePath))
{
New-Item -Path $sitePath -type directory
}
# Check for site
$siteName = "MyWebSite"
$site = Get-WebSite | where { $_.Name -eq $siteName }
if($site -eq $null)
{
Write-Host "Creating site: $siteName"
# Put your New-WebSite code here
}
# Execute your .cmd here
c:\PathToScript\MakeMySite.cmd
Run Code Online (Sandbox Code Playgroud)
您可以.cmd
在PowerShell中运行脚本.
归档时间: |
|
查看次数: |
6425 次 |
最近记录: |