Announcement

Collapse
No announcement yet.

Error while executing powershell 2.0 script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while executing powershell 2.0 script

    Hi,

    I executed the following vb.net code for exchange Powershell 2.0

    Dim Pass As New System.Security.SecureString
    Dim MyPassword As String = Password
    For Each c As Char In MyPassword
    Pass.AppendChar(c)
    Next

    Dim credential As PSCredential = New PSCredential(UserName, Pass)

    Dim connectionInfo As New WSManConnectionInfo(New Uri("http://" & FQDN & "/powershell?serializationLevel=Full"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)

    connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos

    Dim RSpace As Runspace
    Try
    RSpace = System.Management.Automation.Runspaces.RunspaceFac tory.CreateRunspace(connectionInfo)

    Catch ex As Exception
    Throw New Exception("RSPACE: " & ex.Message)
    End Try
    Dim Shell As PowerShell = PowerShell.Create()
    Dim PCommand As New PSCommand

    Dim FQDN As New Microsoft.Exchange.Data.Fqdn(ServerName)
    '

    Dim exchServerName As New Microsoft.Exchange.Configuration.Tasks.ServerIdPar ameter(FQDN)
    try
    PCommand.AddCommand("Get-MailboxDatabase")
    PCommand.AddParameter("Server", exchServerName)
    PCommand.AddParameter("DomainController", PreferredDC)

    Shell.Commands = PCommand
    Catch err As Exception
    Throw New Exception("Run command: " & err.Message & Msg)
    Finally
    RSpace.Dispose()
    RSpace = Nothing
    Shell.Dispose()
    Shell = Nothing
    End Try

    and encountered following error .

    Error detail:
    Cannot process argument transformation on parameter 'Server'. Cannot convert the "Clients.exmtemp.com" value of type "Deserialized.Microsoft.Exchange.Configuration.Tas ks.ServerIdParameter" to type "Microsoft.Exchange.Configuration.Tasks.ServerIdPa rameter".

    any help regarding this error will be appreciated.
    Thanks in advance

    ------------
    Best regards
    Cute Devil
Working...
X