Hi ,
i executed following code to get MailBoxDatabase
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.RunspaceFactory.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
Try
PCommand.AddCommand("Get-MailboxDatabase")
PCommand.AddParameter("Server", New Microsoft.Exchange.Configuration.Tasks.ServerIdParameter(New Microsoft.Exchange.Data.Fqdn(ServerName)))
' PCommand.AddParameter("DomainController", PreferredDC)
Shell.Commands = PCommand
Catch ex As Exception
Throw New Exception("Build command: " & ex.Message)
End Try
Dim results As Collection(Of PSObject)
Dim Msg As String
Dim Databases As String
Try
RSpace.Open()
Shell.Runspace = RSpace
results = Shell.Invoke()
Dim Enm As System.Collections.Generic.IEnumerator(Of System.Management.Automation.PSObject) = results.GetEnumerator
Dim index As Integer = 0
Do While Enm.MoveNext()
Databases = Enm.Current.Members("Identity").Value.ToString '& "" & Enm.Current.Members("AdminDisplayName").Value.ToString
Loop
RSpace.Close()
Catch err As Exception
Throw New Exception("Run command: " & err.Message)
Finally
RSpace.Dispose()
RSpace = Nothing
Shell.Dispose()
Shell = Nothing
End Try
and encountered the following error.
Cannot process argument transformation on parameter 'Server'. Cannot convert the "Clients.exmtemp.com" value of type "Deserialized.Microsoft.Exchange.Configuration.Tasks.ServerIdParameter" to type "Microsoft.Exchange.Configuration.Tasks.ServerIdParameter".
any help regarding above issue will be appreciated.
Thanks in Advance.
Best Regards,
cute devil