I would like to create PowerShell cmdlets that interact with my application at runtime. Are there any best practices on how to accomplish this?
-
what exactly you want to do between powershell and your application?mehmet mecek– mehmet mecek2013-11-06 00:21:58 +00:00Commented Nov 6, 2013 at 0:21
-
i would like to execute some methods defined in my application and pass to them the output from standard powershell commandsSoftwareFactor– SoftwareFactor2013-11-06 00:28:11 +00:00Commented Nov 6, 2013 at 0:28
-
it is possible to execute your application from powershell, you can pass parameters from powershell to your application also. Additionally, you can execute powershell commands from your application like string powershellcommand = "tree"; System.Diagnostics.Process.Start("powershell.exe", powershellcommand);mehmet mecek– mehmet mecek2013-11-06 00:47:01 +00:00Commented Nov 6, 2013 at 0:47
-
Are you expecting these commands to interact with a already running instance of your application or are you wanting your application to just be a powershell commandlet?Scott Chamberlain– Scott Chamberlain2013-11-06 01:08:16 +00:00Commented Nov 6, 2013 at 1:08
-
I want these commands to interact with my application at runtimeSoftwareFactor– SoftwareFactor2013-11-06 13:30:32 +00:00Commented Nov 6, 2013 at 13:30
Add a comment
|
1 Answer
There are several options. You could some form of IPC mechanism: named pipes, memory mapped files, MSMQ, etc. The cmdlets could communicate to the app via a socket. If the app is managed, it could host a WCF endpoint that the cmdlets could use to communicate with the app. You could also expose a COM API and then control the app via that API. I'm sure there are several other ways I've failed to mention.