Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net IIS命令允许_Vb.net_Powershell_Cmdlets - Fatal编程技术网

Vb.net IIS命令允许

Vb.net IIS命令允许,vb.net,powershell,cmdlets,Vb.net,Powershell,Cmdlets,我正在尝试通过命令添加IIS网站。我目前拥有的: ' User input Dim domainname As String = "niels_test" ' System vars Dim basePath As String = "C:\Projecten\Websites\" Dim finalDirname As String = basePath & domainname Dim shell As PowerShell = Po

我正在尝试通过命令添加IIS网站。我目前拥有的:

   ' User input
    Dim domainname As String = "niels_test"

    ' System vars
    Dim basePath As String = "C:\Projecten\Websites\"
    Dim finalDirname As String = basePath & domainname

    Dim shell As PowerShell = PowerShell.Create
    'shell.Commands.AddScript("mkdir """ & finalDirname & """")
    shell.Commands.AddScript("New-Website -name """ & domainname & """ -PhysicalPath '" & finalDirname & "' -port 80")
    Dim results = shell.Invoke()
    If results.Count > 0 Then
        Dim b As New StringBuilder
        For Each PSObject In results
            b.AppendLine(PSObject.BaseObject.ToString)
        Next
    Else
        Throw New Exception("NORESULT")
    End If
如果我将
mkdir
的行注释掉,它会工作。但我不能用这种方式创建新网站。如果我通过服务器本身上的powershell执行该命令。它确实有效

此代码位于
.aspx.vb
文件中


您知道如何使其工作吗?

听起来像是权限问题,您运行网站/appPool的用户没有
“C:\Projecten\Websites\”的权限。

您可以通过向应用程序池分配具有正确权限的用户来解决此问题:

iis管理器->应用程序池->您的池->高级设置->流程模型->标识

或授予您的应用程序池对该文件夹的权限:


文件夹的安全选项卡->编辑/添加->(在位置中选择您的服务器)->IIS AppPool\yourPool

,但奇怪的是,我也不能
获取网站。这会产生相同的错误,我不需要任何目录权限。验证是否为权限的一个好方法是将您知道可以执行
get-website
的用户分配到应用程序池(例如您自己的帐户)。之后不要忘记回收应用程序池。错误是什么?