Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

powershell new-website in VB not working

$
0
0

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


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>