Forum Discussion
vlciho
Oct 02, 2019Copper Contributor
Using @ character in exchange powershell remoting (2010)
Hello, how can i use this: Set-MailPublicFolder -Identity Set-MailPublicFolder -Identity "CN=PF1,CN=Microsoft Exchange System Objects,DC=xxxxxxx,DC=local" -GrantSendOnBehalfTo @{add='domain\john.do...
- Oct 08, 2019
I would recommend you to set complete commands in one string variable and use AddScript function to add the string text as commands
Dim strScript As String = "Set-MailPublicFolder -Identity '"+strIdentity+"' -GrantSendOnBehalfTo @{add= "+ _username +" }" Dim R2 As System.Management.Automation.Runspaces.Runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(pConnectionInfo) R2.Open() Dim P2 As System.Management.Automation.Runspaces.Pipeline = R2.CreatePipeline() P2.Commands.AddScript(strScript); Dim results As Collection(Of PSObject) = P2.Invoke()
R2.Close()For your case, the string text should be like below :
Dim strScript As String = "Set-MailPublicFolder -Identity Set-MailPublicFolder -Identity 'CN=PF1,CN=Microsoft Exchange System Objects,DC=xxxxxxx,DC=local' -GrantSendOnBehalfTo @{add='domain\john.doe'}"
Kevin_Morgan
Oct 08, 2019Iron Contributor
I would recommend you to set complete commands in one string variable and use AddScript function to add the string text as commands
Dim strScript As String = "Set-MailPublicFolder -Identity '"+strIdentity+"' -GrantSendOnBehalfTo @{add= "+ _username +" }"
Dim R2 As System.Management.Automation.Runspaces.Runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(pConnectionInfo)
R2.Open()
Dim P2 As System.Management.Automation.Runspaces.Pipeline = R2.CreatePipeline()
P2.Commands.AddScript(strScript);
Dim results As Collection(Of PSObject) = P2.Invoke()
R2.Close()For your case, the string text should be like below :
Dim strScript As String = "Set-MailPublicFolder -Identity Set-MailPublicFolder -Identity 'CN=PF1,CN=Microsoft Exchange System Objects,DC=xxxxxxx,DC=local' -GrantSendOnBehalfTo @{add='domain\john.doe'}"vlciho
Oct 09, 2019Copper Contributor
Hi, Kevin_Morgan
Thank you very much! This is works! 😉
Dim strScript As String = "Set-MailPublicFolder -Identity '" + strIdentity + "' -GrantSendOnBehalfTo @{add='" + My.Settings.txtDomain.ToString + "\" + _username + "'}"
Dim R2 As System.Management.Automation.Runspaces.Runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(pConnectionInfo)
R2.Open()
Dim P2 As System.Management.Automation.Runspaces.Pipeline = R2.CreatePipeline()
P2.Commands.AddScript(strScript)
Dim results As Collection(Of PSObject) = P2.Invoke()
R2.Close()