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...
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