Hi,
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 anything or creates the site using a webservice in VB. Even tried with more parameters.
A part of the simple code in VB:
<%@ 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
<System.Web.Services.WebService(Namespace:="Removed")> _
Public Class NAVservice
Inherits WebService
<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
Using the same Webservice with different Powershell commands works fine though.
Could somebody point me in the right directions? I'm out of ideas.
Thanks!
Nick