document.write('\
<div class="poshcode code posh">\
<style type="text/css">\
.posh li.li2, .posh li.li1 { list-style-type:decimal-leading-zero; white-space:nowrap;}');
document.write(".syntax .posh { overflow: auto; background-color:#EAEAEA; border:1px solid #DDDDDD; border-width: 1px 1px 0px 1px;}\
.syntax .poshcredit {\
background-color:#EAEAEA;\
border-bottom:1px solid #DDDDDD;\
color:#666666;\
font-size:85%;\
overflow:hidden;\
padding:0.5em 1em;\
}");
document.write("/**\
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann\
 * (http://qbnz.com/highlighter/ and http://geshi.org/)\
 */\
.posh .de1, .posh .de2 {font: normal normal 1em/1.2em Consolas, 'Bitstream Vera Sans Mono', 'Courier New', monospace; margin:0; padding:0; background:none; vertical-align:top;}\
.posh  {font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', monospace;}\
.posh .imp {font-weight: bold; color: red;}\
.posh li, .posh .li1 {background: #ffffff;}\
.posh .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}\
.posh .li2 {background: #f8f8f8;}\
.posh .kw1 {color: #666699; font-weight: bold;}\
.posh .kw2 {color: #333399; font-weight: bold; font-style: italic;}\
.posh .kw3 {color: #003366; font-weight: bold;}\
.posh .kw4 {color: #660033;}\
.posh .co1 {color: #666666; font-style: italic;}\
.posh .coMULTI {color: #666666; font-style: italic;}\
.posh .es0 {color: #000099; font-weight: bold;}\
.posh .br0 {color: #333;}\
.posh .sy0 {color: #66cc66;}\
.posh .st0 {color: #009900;}\
.posh .nu0 {color: #cc66cc;}\
.posh .me1 {color: #003366;}\
.posh .me2 {color: #003366;}\
.posh .re0 {color: #0066cc; font-style: italic;}\
.posh .re1 {font-style: normal;}\
.posh .re2 {color: #000066;}\
.posh .re3 {color: #660033; font-weight: bold;}\
.posh .re4 {color: #003366; font-weight: bold;}\
.posh span.xtra { display:block; }\
");
document.write('</style>');
document.write('<div class="syntax"><div class="posh" style="font-family: Consolas, \'Bitstream Vera Sans Mono\', \'Courier New\', monospace;"><ol><li class="li1"><div class="de1"><span class="kw1">function</span> <span class="re0">Invoke-<span class="re1">SSH</span></span> <span class="br0">&#123;</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">param</span> <span class="br0">&#40;</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re4"><span class="br0">&#91;</span><span class="kw3">string</span><span class="br0">&#93;</span></span><span class="re3">$Server</span> <span class="sy0">=</span> <span class="st0">&quot;$(throw \'Server is a mandatory parameter.\')&quot;</span>,</div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re3">$Credential</span> <span class="sy0">=</span> <span class="st0">&quot;$(throw \'Credential is a mandatory parameter.\')&quot;</span>,</div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re4"><span class="br0">&#91;</span><span class="kw1">switch</span><span class="br0">&#93;</span></span><span class="re3">$Echo</span> <span class="sy0">=</span> <span class="re3">$true</span>,</div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re4"><span class="br0">&#91;</span><span class="kw3">string</span><span class="br0">&#93;</span></span><span class="re3">$Command</span> <span class="sy0">=</span> <span class="st0">&quot;$(throw \'Command is a mandatory parameter.\')&quot;</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Since function name is same as cmdlet, we have to fully-qualify cmdlet name using format Snapin\\Cmdlet</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re3">$ShellObject</span> <span class="sy0">=</span> Netcmdlets\\<span class="re0">Invoke-<span class="re1">SSH</span></span> <span class="re2">-Server</span> <span class="re3">$Server</span> <span class="re2">-Credential</span> <span class="re3">$Credential</span> <span class="re2">-Force</span> <span class="re2">-Command</span> <span class="re3">$Command</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Foreach loop creates a string array from the output, one line per array item</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re3">$Output</span> <span class="sy0">=</span> <span class="re3">$ShellObject</span> <span class="sy0">|</span> <span class="re0">ForEach-<span class="re1">Object</span></span> <span class="br0">&#123;</span> <span class="br0">&#40;</span><span class="re3">$_</span>.<span class="me1">Text</span><span class="br0">&#41;</span>.<span class="kw2">split</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">`n</span>&quot;</span><span class="br0">&#41;</span> <span class="br0">&#125;</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># By default will simulate a bash-like prompt with username and server. Good for pasting in emails.</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re3">$Echo</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re3">$UserName</span> <span class="sy0">=</span> <span class="re3">$Credential</span>.<span class="me1">UserName</span> <span class="re2">-replace</span> <span class="st0">&quot;\\\\&quot;</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">Write-<span class="re1">Host</span></span> <span class="re2">-foregroundcolor</span> Yellow <span class="st0">&quot;$UserName@$Server # $Command&quot;</span></div></li>\
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>\
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">Write-<span class="re1">Output</span></span> <span class="re3">$Output</span></div></li>\
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>\
</ol></div>');document.write('<div class="poshcredit"><a style="float:right;" href="http://poshcode.org/get/646" title="download file">download</a><a href="http://poshcode.org/?show=646" title="full view">This Script</a> brought to you by <a href="http://PoshCode.org">PoshCode</a>\
</div>\
</div>\
</div>');