我一直在尝试使用powershell命令"New-Website Testsite"创建一个新网站。 命令工作原理在Powershell中很好,但不会返回任何内容或使用VB中的Web服务创建网站。甚至尝试使用更多参数。
I've been trying to create a new website using the powershell command "New-Website Testsite" Command works fine in Powershell but does not return anythingor creates the siteusing a webservice in VB. Even tried with more parameters.
VB中简单代码的一部分:
A part of the simple code in VB:
<%@ WebService Language =" VB"类= QUOT; NAVservice" %> 选项严格关闭
<%@ WebService Language="VB" Class="NAVservice" %> Option Strict Off
Imports System.Web.Services Imports System.Collections.ObjectModel Imports System.Management.Automation Imports System.Management.Automation.Runspaces
Imports System.Web.Services Imports System.Collections.ObjectModel Imports System.Management.Automation Imports System.Management.Automation.Runspaces
< System.Web.Services.WebService(Namespace:=" ;删除")> _ $ 公共舱NAV服务 继承WebService
<System.Web.Services.WebService(Namespace:="Removed")> _ Public Class NAVservice Inherits WebService
<的WebMethod()> _ $ Public Sub NAVdeployment() Dim runspace As Runspace = RunspaceFactory.CreateRunspace() 尝试 runspace.Open() Dim pipeline As Pipeline = runspace.CreatePipeline() pipeline.Commands.AddScript(" Import-Module WebAdministration") pipeline.Commands.AddScript(" New-Website NiSo") pipeline.Invoke() 最后为 runspace.Close() 结束尝试 结束点 结束类
<WebMethod()> _ Public Sub NAVdeployment() Dim runspace As Runspace = RunspaceFactory.CreateRunspace() Try runspace.Open() Dim pipeline As Pipeline = runspace.CreatePipeline() pipeline.Commands.AddScript("Import-Module WebAdministration") pipeline.Commands.AddScript("New-Website NiSo") pipeline.Invoke() Finally runspace.Close() End Try End Sub End Class
使用具有不同Powershell命令的相同Web服务可以正常工作。 有人能指出我正确的方向吗?我没有想法。
Using the same Webservice with different Powershell commands works fine though. Could somebody point me in the right directions? I'm out of ideas.
谢谢! Nick
Thanks! Nick
推荐答案
尼克,
你有这么严格宣布选项严格关闭的任何理由。
Any reason you have so strict declared Option Strict Off.
选项Strict Off是所有迟到的主要原因绑定错误,所以首先尝试解决。
Option Strict Off is a main reason for all kind of late binding errors so try to solve that first.
更多推荐
在VB中的powershell新网站无法正常工作
发布评论