<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx</link><description>First, let me apologize for the lack of posts to this blog. Out original team goal was to have a new post every month, but holidays/vacations/work got in the way. I&amp;rsquo;ll try to restart this rhythm. For this first post of the New Year, I&amp;rsquo;m going</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10353873</link><pubDate>Thu, 27 Sep 2012 18:13:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10353873</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;Now that Windows Server 2012 is out, my recommendation for you would to be use the Management OData IIS Extension (&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/b/wmi/archive/2012/09/10/powershell-cmdlets-invocation-through-management-odata-using-wcf-client.aspx"&gt;blogs.msdn.com/.../powershell-cmdlets-invocation-through-management-odata-using-wcf-client.aspx&lt;/a&gt;). &amp;nbsp;This is a new feature designed around calling PowerShell through a REST interface. &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10353873" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10353781</link><pubDate>Thu, 27 Sep 2012 13:19:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10353781</guid><dc:creator>Barfi</dc:creator><description>&lt;p&gt;Steve Lee: Thanks for the informative post !&lt;/p&gt;
&lt;p&gt;We are performing a series of Powershell commands in batch mode. Objects are returned from one powershell command are to be used in the subsequent command. This if I run by embedding a batch script within args[3] or the commandline param, there will be a problem as all$variables will be substituted. &lt;/p&gt;
&lt;p&gt;One option then is to run each command of the script as a separate &amp;quot;Command custom SOAP action&amp;quot;.&lt;/p&gt;
&lt;p&gt;1) In that case, is it possible to de-serialize all objects to text and then using the stderr+stdout of a command and again serialize the text into objects for the next command.&lt;/p&gt;
&lt;p&gt;2) We have one more problem where when another powershell module is loaded in one &amp;quot;Command custom SOAP Action&amp;quot;. We get an error - &amp;quot;Process is terminated due to StackOverflowException&amp;quot; as part of the output.&lt;/p&gt;
&lt;p&gt;Are there any known restrictions in each Powershell shell EPR ? How to avoid this/handle this.&amp;quot; &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10353781" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10303258</link><pubDate>Wed, 09 May 2012 15:57:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10303258</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;It appears that this Open Source project successfully implemented session key HTTP encryption: &lt;a rel="nofollow" target="_new" href="https://github.com/zenchild/WinRM"&gt;github.com/.../WinRM&lt;/a&gt;. &amp;nbsp;I have not tried that Ruby client myself so I can&amp;#39;t speak to it&amp;#39;s quality.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10303258" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10303255</link><pubDate>Wed, 09 May 2012 15:55:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10303255</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;For cross-platform, it&amp;#39;ll probably be easier to enable HTTPS instead of trying to implement session key based encryption (although you could follow the spec here: &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/cc251574(v=PROT.10).aspx"&gt;msdn.microsoft.com/.../cc251574(v=PROT.10).aspx&lt;/a&gt;).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10303255" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10302895</link><pubDate>Wed, 09 May 2012 07:50:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10302895</guid><dc:creator>Barak</dc:creator><description>&lt;p&gt;Well, I want to upload a script (which may be generated/modified by my code first) and then execute it. I think I have the upload sorted (using Base64) and I expect the files to be fairly small, so the Base64 overhead should not be a huge problem. I can&amp;#39;t use BITS since the client running this may not be running Windows - it&amp;#39;s a cross-platform project.&lt;/p&gt;
&lt;p&gt;The next thing I have to tackle is encryption. The remote windows machines have encryption enabled (over HTTP on port 5985) and use NTLM authentication. Is there a sample somewhere showing how to encrypt the messages?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10302895" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10302299</link><pubDate>Tue, 08 May 2012 17:02:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10302299</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;You could certainly use this technique to transfer a file using base64 encoding. &amp;nbsp;However, it won&amp;#39;t perform very well since the binary file would go through several levels of encoding (even if you skip PowerShell and just use cmd.exe). &amp;nbsp;Recommendation is to use BITS to transfer the file if possible which goes over HTTP. &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa362708(v=vs.85).aspx"&gt;msdn.microsoft.com/.../aa362708(v=vs.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you could articulate your specific scenario further (assuming BITS is not something you are able to use), I could give you a better answer.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10302299" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10302111</link><pubDate>Tue, 08 May 2012 07:41:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10302111</guid><dc:creator>Barak</dc:creator><description>&lt;p&gt;Kind of late to be asking this, but is there any way to use the same technique to transfer a file from the client to the server? Maybe pass a base64 encoded string as a parameter somehow?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10302111" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10241122</link><pubDate>Wed, 23 Nov 2011 23:35:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10241122</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;@JMD Software, I did some research and it appears this was a known issue in Win7/Win2k8R2. &amp;nbsp;PowerShell is designed to not prompt if stdin is redirected (which would be the case via WinRS). &amp;nbsp;So there is no way to use WinRS Protocol to establish an interactive PowerShell session. &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10241122" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10241111</link><pubDate>Wed, 23 Nov 2011 22:54:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10241111</guid><dc:creator>Steve Lee [MSFT]</dc:creator><description>&lt;p&gt;@JMD Software, it seems that there may be a issue preventing an interactive PowerShell session via WinRS from working correctly. On my Win2k8R2 box, just using &amp;quot;winrs -r:foo powershell.exe&amp;quot;, I&amp;#39;m able to observe the behavior I believe you are describing. &amp;nbsp;Executing &amp;quot;winrs -r:foo cmd&amp;quot; works, but starting powershell.exe under that remote cmd session exhibits the same problem. &amp;nbsp;Due to how PowerShell uses the console, it appears that it may not be possible to use WinRS protocol for interactive PowerShell and you may need to implement PSRP (&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/dd357801(v=PROT.10).aspx"&gt;msdn.microsoft.com/.../dd357801(v=PROT.10).aspx&lt;/a&gt;).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10241111" width="1" height="1"&gt;</description></item><item><title>re: Using WS-Man to invoke a Powershell Cmdlet</title><link>http://blogs.msdn.com/b/wmi/archive/2011/01/25/using-ws-man-to-invoke-a-powershell-cmdlet.aspx#10241062</link><pubDate>Wed, 23 Nov 2011 20:11:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10241062</guid><dc:creator>JMD Software</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I’ve been trying to get the interactive pattern to work so I can create a custom remote powershell client. When I invoke powershell with a script as argument, input and output work fine with multiple receive messages. But when I invoke powershell with a script and “-NoExit”, receive stops working as soon as the script is done executing. I can send the request, but it’s waiting on something and never returns a response. I can still send messages such as “del file.txt” and they are processed correctly, so it’s just the receive message that stops working. Same thing happens when I invoke powershell without any arguments, the copyright text is displayed, but after that receive never returns anything.&lt;/p&gt;
&lt;p&gt;Any idea why I’m getting this behavior?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Johan &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10241062" width="1" height="1"&gt;</description></item></channel></rss>