none
Adding Parameter to Command in to connect Remote powershell thorugh VB.net RRS feed

  • Question

  • Hello All

    I am writing a code in VB.net and trying to call Get-MoveRequestStatistics  | ft DisplayName, Status, RemoteDatabaseName, TargetDatabase,TotalMailboxSize,PercentComplete from O365 remote runspace. When i run the code it throws me a error message :

    An unhandled exception of type 'System.Management.Automation.RemoteException' occurred in System.Management.Automation.dll

    Additional information: A parameter cannot be found that matches parameter name 'DisplayName,Status,PercentComplete'.

    I tried changing the code by mentioning only one parameter still no luck. Need suggestion how to pipe the parameters to command in VB.net

    Here is my code for reference:

    Dim runspace As Runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(MyConnectionInfo.Instance.connectionInfo)
            runspace.Open()
            Dim plPileLine As Pipeline = runspace.CreatePipeline()
            Dim gmGetMove As New Command("Get-MoveRequestStatistics")
            gmGetMove.Parameters.Add("DisplayName")
            gmGetMove.Parameters.Add("Status")
            gmGetMove.Parameters.Add("PercentComplete")
            plPileLine.Commands.Add(gmGetMove)
            'plPileLine.Commands.Add("Out-String")

           Dim RsResultsresults = plPileLine.Invoke()

    thanks

    Sriram


    Thanks Sriram

    Monday, September 29, 2014 7:55 PM

All replies

  • 'DisplayName,Status,PercentComplete' aren't parameters they are properties that will be in the results. A parameter would be something like Identity if you want to retrieve the statistics for a particular Move Request so you should use it like

            Dim gmGetMove As New Command("Get-MoveRequestStatistics")
            plPileLine.Commands.Add(gmGetMove)
            Dim RsResultsresults = plPileLine.Invoke()
            For Each obj As PSObject In RsResultsresults
                Console.WriteLine(obj.Properties("DisplayName").Value)
                Console.WriteLine(obj.Properties("Status").Value)
                Console.WriteLine(obj.Properties("PercentComplete").Value)
            Next
    Cheers
    Glen

    Tuesday, September 30, 2014 5:21 AM
  • Thanks Glen

    If i want to users identity parameter as a input txt file, instead specifying identity parameter for each user mailbox how to modify the code. 


    Thanks Sriram

    Tuesday, September 30, 2014 6:15 AM
  • Just add that as a parameter where IndentityVarible is the value your feeding it eg

    Dim gmGetMove As New Command("Get-MoveRequestStatistics") gmGetMove.Parameters.Add("Identity",IndentityVarible)
    plPileLine.Commands.Add(gmGetMove) Dim RsResultsresults = plPileLine.Invoke()

    you'll need a separate request for each identity.

    Cheers
    Glen

    Wednesday, October 1, 2014 3:55 AM