Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Calling powershell in VB

$
0
0

Dear Expert,

Need your support to working with VB, this is my first time i am trying to develop program in VB and calling powershell command,

following below microsoft link , but did not success however could any one guide me steps by steps for initailly...

http://msdn.microsoft.com/en-us/library/bb332449(v=exchg.80).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

Imports

System.Management.Automation

Imports

System.Management.Automation.Host

Imports

System.Management.Automation.Runspaces

Imports

System.Collections.Generic

Imports

System.Collections.ObjectModel

Public

Class

Form1

Dim Out As

Object

PrivateProperty info As

Object

PrivateSub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)HandlesMyBase

.Load

Dim rsConfig As

RunspaceConfiguration

rsConfig =

RunspaceConfiguration

.Create()

Dim snapInException As

PSSnapInException

Diminfo = rsConfig.AddPSSnapIn(

"Microsoft.Exchange.Management.PowerShell.Admin"

, snapInException)

Dim myRunSpace As

Runspace

myRunSpace =

RunspaceFactory

.CreateRunspace(rsConfig)

myRunSpace.Open()

Dim pipeLine As

Pipeline

pipeLine = myRunSpace.CreatePipeline()

Dim myCommand AsNewCommand("Get-Command"

)

pipeLine.Commands.Add(myCommand)

Dim commandResults AsCollection(OfPSObject

)

commandResults = pipeLine.Invoke()

End

Sub

End

Class


Viewing all articles
Browse latest Browse all 3509

Trending Articles



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