Import-Module RemoteDesktop
$ConnBroker = (Get-RDConnectionBrokerHighAvailability -ConnectionBroker "dm3us050.dm3.wizmoworks.net").ActiveManagementServer
Set-RDSessionHost -SessionHost $server -ConnectionBroker $ConnBroke -NewConnectionAllowed $action
And the following c# code: public static void RunPowershellCommand(string scriptPath, string[,] variables = null)
{
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
//scriptInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
Pipeline pipeline = runspace.CreatePipeline();
Command myCommand = new Command(scriptPath, false);
if (variables[0, 0] != null)
{
for (int i = 0; i < variables.GetLength(0); i++) //Add all the powershell variables we might need in the partner specific.
{
runspace.SessionStateProxy.SetVariable(variables[i, 0], variables[i, 1]);
}
}
pipeline.Commands.Add(myCommand);
Collection<PSObject> psObjects;
psObjects = pipeline.Invoke();
runspace.Close();
}
{"The term 'Get-RDConnectionBrokerHighAvailabil ity' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.