![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | calling winrm from a custom cmdlet Hi, I am trying to write a cmdlet as part of a PSSnapin (in C#) that calls winrm and then prints the output back on the console. For example, I have a cmdlet called Get-AvailableX, which would take some input parameters and transform them into an argument string to pass to a winrm enumerate call (in this case, to enumerate all instances of X). I would then like all of the returned instances printed out on the powershell console. The only way I have discovered to do this so far is using the System.Diagnostics.Process class, but when I try that, I keep getting exceptions saying "The system can not find the file specified". I am simply trying the following (where args is a string I constructed beforehand): System.Diagnostics.Process.Start("winrm.cmd " + args); If I type 'winrm' on the powershell console I get back the expected results. Any ideas why I can't get it going through my C# code? Thanks, Simon |
My System Specs![]() |
| | #2 (permalink) |
| | Re: calling winrm from a custom cmdlet Quote: > I am simply trying the following (where args is a string I constructed > beforehand): > System.Diagnostics.Process.Start("winrm.cmd " + args); > > If I type 'winrm' on the powershell console I get back the expected > results. Any ideas why I can't get it going through my C# code? I don't know what kind of environment will be inherited by the host, but how about trying the full path just for fun: [System.Diagnostics.Process]::Start("C:\WINDOWS\system32\winrm.cmd") Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| winrm invoke a custom action | PowerShell | |||
| winrm connection to custom web service | PowerShell | |||
| Could not load type when executing a custom cmdlet | PowerShell | |||
| Custom cmdlet suite best practices: pipe .NET objects? ...or XmlDocuments? | PowerShell | |||
| [Ann] Format-Graph custom CmdLet to display graphics within PowerShell | PowerShell | |||