Questions tagged [pshost]

8 questions
5
votes
3 answers

How to extract $lastexitcode from c# powershell script execution

I've got a scipt executing in C# using the powershell async execution code on code project…
scope_creep
  • 4,213
  • 11
  • 35
  • 64
5
votes
1 answer

How to capture a Powershell CmdLet's Object output when the CmdLet is programmatically Invoked from C#

Background PowerShell 3 with SDK C# with Framework 4.5 Implementation I have implemented my own PSHost alogn with PSHostUserInterface. In PSHostUserInterface I override all Write... methods and colleting the to one variable which serves the…
krs
  • 543
  • 2
  • 17
2
votes
3 answers

how to establish and enter a remote session using runspace in powershell

I am trying to establish a session with a remote host B from my machine A, within a C# code. I am using runspace API for that. the code snippet is provided below Runspace runspace = RunspaceFactory.CreateRunspace(); …
user1156612
  • 41
  • 1
  • 3
1
vote
1 answer

Management automation host rectangle: bottom cannot be greater than or equal to top

I'm getting an error saying bottom cannot be greater than or equal to top. I'm using the Rectangle constructor documented here:…
silicontrip
  • 906
  • 7
  • 23
1
vote
2 answers

Powershell Sqlcmd popup in c#

I have a PSHost object executing a Powershell script myscript.ps1 and that .ps1 script is executing sqlcmd.exe to get what it needs done. Is there a way to keep it from popping up empty sqlcmd dos prompts (as it seems to do)?
maxfridbe
  • 5,872
  • 10
  • 58
  • 80
1
vote
1 answer

Rendering Powershell Output with Complex Commands

I'm trying to execute a PS1 file via a C# application and capture/segment the output based on severity. Error, Debug, Info, etc. This is a Windows Form application. Here's the Run Method, which I call on a button click: PowerShell m_PSInst =…
RAhnemann
  • 31
  • 3
1
vote
0 answers

PSHost PromptForChoice format ChoiceDescription

In my PSCmdlet class I'm asking the user to make a choice with PromptForChoice. The user is prompted to select the connectionstring he wants to use. I can't manage to give the ChoiceDescriptions the right format. choiceDescriptions.Add(new…
Sybren
  • 1,071
  • 3
  • 17
  • 51
0
votes
1 answer

Custom PSHost, Get-Credential cmdlet in C#

i am trying to implement a custom PSHost class for the purpose of crafting GUIs for Power Shell scripts. I have taken the code here as a base and started adapting it for GUI…
VikFreeze
  • 13
  • 6