Powershell-通过Web界面调用时,新网站cmdlet不起作用 [英] Powershell - new-website cmdlet not working when called via web interface

查看:84
本文介绍了Powershell-通过Web界面调用时,新网站cmdlet不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以为我提供以下帮助:

I hope someone can help me with the following :

我创建了一个脚本来基于现有站点安装网站.
该脚本执行几个步骤-复制目录,还原数据库,创建网站和应用程序池等.
在Powershell CLI的管理员帐户下可以正常运行.
我为此脚本创建了一个WinForms前端,该前端引用了Powershell,并且也很好地执行了该脚本.
现在,我想为其创建一个Web前端. (如此处所述: http ://devinfra-us.blogspot.com/2011/02/using-powershell-20-from-aspnet-part-1.html )
但是,我无法通过网络前端使用新网站" cmdlet.脚本中的所有其他步骤都可以正常工作,包括"new-WebappPool"(我可以在IIS管理器中看到新的appPool).我没有任何错误..
我已确保脚本以管理员权限运行(此时安全性不是 )

以下是Powershell脚本的一些输出:

I’ve created a script to install a web site based on an existing site.
The script performs several steps - copy dirs, restore a DB, create website and application pool etc.
It runs fine from the Powershell CLI under an Administrator account.
I created a WinForms frontend for this script that references Powershell and also executes that script just fine.
Now I want to create a web frontend for it. (as explained here : http://devinfra-us.blogspot.com/2011/02/using-powershell-20-from-aspnet-part-1.html)
However I can’t get the ‘new-website’ cmdlet to work via the web frontend. All the other steps in the script work, including ‘new-WebappPool’ (I can see the new appPool in IIS manager). I don’t get any errors..
I’ve made sure the script runs with Administrator rights (security is not a concern at this point)

Below is some output from the Powershell transcript :

**********************
Windows PowerShell transcript start
Start time: 20200106164117
Username: NNN-WEB\adminArr     <-- Administrator account
RunAs User: NNN-WEB\adminArr
Machine: NNN-WEB (Microsoft Windows NT 10.0.14393.0)
Host Application: c:\windows\system32\inetsrv\w3wp.exe -ap DefaultAppPool -v v4.0 -l webengine4.dll -a \\.\pipe\iisipmd4bdced8-d455-428b-b9ef-8b3e2bfb38dd -h C:\inetpub\temp\apppools\DefaultAppPool\DefaultAppPool.config -w  -m 0 -t 20 -ta 0
Process ID: 8448
PSVersion: 5.1.14393.3383
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.3383
BuildVersion: 10.0.14393.3383
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1

推荐答案

尽管在我的脚本中我也使用了Jalpa示例中提到的命令,但无论如何我还是尝试了他的示例脚本.我收到错误消息无法添加类型为站点"的重复集合条目,且其唯一键属性为名称,ID",分别设置为"Mike3,2"-我没有使用自己的脚本...
由于此错误,我发现如果已经有一些现有站点,则还必须指定new-website命令的"ID"参数-例如"new-website -Name"testsite" -Id 4等. '.该ID必须是其他任何站点都未使用的数字.
这样就可以了:-)

Although in my script I also used the commands mentioned in Jalpa's example, I tried his example script anyway. I got the error 'Cannot add duplicate collection entry of type 'site' with unique key attributes 'name, id' respectively set to 'mike3, 2' - which I didn't get using my own script...
Thanks to this error, I figured out that if there are already some existing sites, you also have to specify the 'ID' parameter of the new-website command - so like 'new-website -Name "testsite" -Id 4 etc.'. The ID has to be a number not in use by any other sites.
This made it work :-)

这篇关于Powershell-通过Web界面调用时,新网站cmdlet不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆