title: Getting exception while running PowerShell script in C# - The term 'xxxxxx' is not recognized as the name of a cmdlet, function, script file'
body: <p>I'm running PowerShell script in C# code using this method.</p>
  <pre><code>PowerShell psExec1 = PowerShell.Create();
  string script = File.ReadAllText(downloadPathScript1);
  psExec1.AddScript(script);
  Collection&lt;PSObject&gt; results2;
  results2 = psExec1.Invoke();
  </code></pre>
  <p>In downloadPathScript1 I'm giving file path of .ps1 file Even after adding correct command or script I'm getting this exception.</p>
  <p><em>The term 'Get-Item C:\Program Files\OneDriveLib.dll | Unblock-File' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</em></p>
  <p>When I run same script in PowerShell it is working as expected. I'm trying to run this script/commands. What could be the cause of this exception?</p>
  <pre><code>Unblock-File -Path &quot;C:\ODTool - Copy\OneDriveLib.dll&quot;
  Import-Module &quot;C:\ODTool - Copy\OneDriveLib.dll&quot;
  
  $Status = Get-ODstatus -ByPath &quot;C:\Users\OneDrive\Documents\Test.txt&quot;
  </code></pre>