public void InvokeCommands(PSCommand[] profileCommands)
{
lock (_dispatcherLock)
{
using (var powerShell = System.Management.Automation.PowerShell.Create())
{
powerShell.Runspace = _runspace;
foreach (PSCommand command in profileCommands)
{
powerShell.Commands = command;
powerShell.AddCommand("out-default");
powerShell.Invoke();
}
}
}
}