private async Task RunPowerShellCommand(ServerManagementClient client, NodeResource node, SessionResource session, PowerShellSessionResource ps) { // run a command var result = await client.PowerShell.InvokeCommandAsync(ResourceGroup, node.Name, session.Name, ps.SessionId, "dir c:\\"); Assert.NotNull(result); // did the command complete successfully?t Assert.True(result.Completed); // did we get some results? var found = false; foreach (var r in result.Results) { found = true; WriteLine(string.Format(" {0}", r.ToJson())); } Assert.True(found); }
private async Task RunLongPowerShellCommand(ServerManagementClient client, NodeResource node, SessionResource session, PowerShellSessionResource ps) { // run a command var result = await client.PowerShell.InvokeCommandAsync(ResourceGroup, node.Name, session.Name, ps.SessionId, "dir c:\\ ; sleep 20 ; dir c:\\windows"); Assert.NotNull(result); // this should return false because 20 seconds is too long... // did the command complete successfully? Assert.False(result.Completed); // did we get some results? var found = false; foreach (var r in result.Results) { found = true; WriteLine(string.Format(" {0}", r.ToJson())); } Assert.True(found); PowerShellCommandStatus more; found = false; // go back for some more results. do { more = await client.PowerShell.GetCommandStatusAsync(ResourceGroup, node.Name, session.Name, ps.SessionId, PowerShellExpandOption.Output); foreach (var r in more.Results) { found = true; WriteLine(string.Format(" {0}", r.ToJson())); } } while (!(more.Completed ?? false)); Assert.True(found); Assert.True(more.Completed); }
private async Task GetTabCompletionResults(ServerManagementClient client, NodeResource node, SessionResource session, PowerShellSessionResource ps) { bool found; // try to get tab command completion var results = await client.PowerShell.TabCompletionAsync(ResourceGroup, node.Name, session.Name, ps.SessionId, "dir c:\\"); Assert.NotNull(results); found = false; foreach (var s in results.Results) { found = true; WriteLine(string.Format(" {0}", s.ToJson())); } Assert.True(found); }