<h2>Embed and execute multiple lines in a Powershell script</h2><br/><div style="overflow-x:auto"><article><div ><h3 >Issue </h3><section><ul style="list-style-position: inside;"><li>The below article provides info on how to run single line scripts<br /><br /><a href="https://support.servicenow.com/kb_view.do?sysparm_article=KB0821628">https://support.servicenow.com/kb_view.do?sysparm_article=KB0821628</a><br /><br /></li><li>How to execute a Powershell script with multiple lines of code inside it ?</li></ul></section></div><div ><h3 >Release</h3><section><ul style="list-style-position: inside;"><li>All</li></ul></section></div><div ><h3 >Resolution</h3><section><ol style="list-style-position: inside;"><li>Create a script and test it to be working. The script can get arguments.<br /><br /></li><li>Upload the script to MID servers using the UI in: <strong>Pattern Designer->Uploaded Files.</strong> Make sure to take a note of the directory this file was uploaded to.<br /><br /></li><li>Use a <strong>Put File</strong> step in a pattern and this will make sure to copy the script from the MID server to the remote target. The return value of this operation is the full path of the script.<br /><br /></li><li>Use the return value from the above step to run the script locally on a target - you may add arguments per your script.<br /><br /></li><li>If you do not see the uploaded file, try to do the following, which might not be needed after following the <a title="documentation" href="https://docs.servicenow.com/csh?topicname=t_TransferFilePatDef.html&version=latest" rel="nofollow">documentation</a><br /><br /> <ul style="list-style-position: inside;"><li>Go to <strong>MID ->Script Files</strong> and edit the file "<strong>DiscoveryUtilityFiles.properties</strong>"<br /><br /></li><li>This is a <strong>key=value</strong> file<br /><br /></li><li>Add a <strong>Logical name = relative path (from step 2)</strong>. Note that the relative path is something like <strong>MID_Install>\bin\sw_wmi\bin</strong></li></ul> </li></ol></section></div></article></div>