简体   繁体   English

用于将Web部署包部署到IIS服务器的Powershell脚本(远程)

[英]Powershell script for web deploy package to IIS server (Remote)

I am a developer but I don't have permission to deploy a package. 我是开发人员,但没有部署程序包的权限。 If I provide a power shell script and Web deployment package (.zip) to my network admin, he will deploy it to the server. 如果我向网络管理员提供power shell scriptWeb deployment package (.zip) ,他将把它部署到服务器。

Power shell needs to ask path to deploy (IIS web site path). Power Shell需要询问path to deploy (IIS网站路径)。 The script has to pickup WDP, extract it, and deploy to given path on the IIS server. 该脚本必须提取WDP,将其提取,然后部署到IIS服务器上的给定路径。

Example: ExampleMVC.zip (WDP)
 path: \\iisprod1\inetpub\wwwroot\iapps

Now I want deploy this package to that path. 现在,我想将此软件包部署到该路径。 How can I we do that? 我该怎么办?

ZIP deploy package usually comes with a .cmd file (and some xml files too) which should be ran with /Y parameter in order to deploy the package on the current computer's IIS web server. ZIP部署程序包通常带有一个.cmd文件(以及一些xml文件),应使用/Y参数运行该命令,以便将该程序包部署在当前计算机的IIS Web服务器上。 If you want to change the web application path, do it while you building the ZIP package in your visual studio. 如果要更改Web应用程序的路径,请在Visual Studio中构建ZIP包时进行更改。

It be easier to just use a batch script. 仅使用批处理脚本会更容易。 I would add the path's you want to deploy to in a separate file. 我将要部署到的路径添加到一个单独的文件中。 It could be done like this: 可以这样完成:

@echo off
set "scriptPath=/where/the/files/are"
for /F %%a IN (deployment-list.txt) DO (
     REM Will prompt for password and set T: (temp) drive to path
     net use T: \\%%a /u:administrator *
     copy %scriptPath%\ExampleMVC.zip t:\
     net use t: /d
)

Or with just one path and no loop: 或只有一条路径且没有循环:

 REM Will prompt for password and set T: (temp) drive to path
 net use T: \\iisprod1\inetpub\wwwroot\iapps /u:administrator *
 copy \path\to\file\ExampleMVC.zip t:\
 net use t: /d

Also if you would like to have the extracted content, simply extract it first and copy the contents over alternatively like this: 另外,如果您要提取的内容,只需先提取它,然后像下面这样复制内容即可:

 REM Will prompt for password and set T: (temp) drive to path
 net use T: \\iisprod1\inetpub\wwwroot\iapps /u:administrator *
 copy \path\to\file\ExampleMVC\* t:\
 net use t: /d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM