title: How to execute more than one power shell command in a single .ps1 file
body: <p>I am trying to run more than one powershell command(with parameters in each command) in a single .ps1 file.</p>
  
  <p>i.e.
  In the Azure powershell i need to run these 3 commands sequentially </p>
  
  <pre><code>Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Bypass -Force 
  Import-AzurePublishSettingsFile 
  New-AzureService
  </code></pre>
  
  <p>All the above 3 command receive different parameters. I wanted to keep them in a single .ps1 file.</p>
  
  <p>I am trying as bellow, it is not working although not giving any exception</p>
  
  <pre><code> using (PowerShell ps = PowerShell.Create())
  {
   string Filepath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"path of .ps1 file");
   string Script = File.ReadAllText(Filepath);  
  
   IDictionary Param = new Dictionary&lt;String, String&gt;();
   Param.Add("–PublishSettingsFile", @"path of pubsetting file");
   Param.Add("-ServiceName", CloudServiceName);
   Param.Add("-Location", Location);
  
  var result = 
  PowerShell.Create().AddScript(Script).AddParameters(Param).Invoke();
  }
  </code></pre>