title: How to get value from powershell script into C# variable?
body: <p>I have .ps1 script which should return me SID of current user (or administrator). But i have no idea how can i get this value from that script into my C# code. Can somebody help me, please?</p>
  
  <p>Currently i am calling one script in this way:</p>
  
  <pre><code>ProcessStartInfo newProcessInfo = new ProcessStartInfo();
  newProcessInfo.FileName = @"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe";
  newProcessInfo.Verb = "runas";
  newProcessInfo.Arguments = @"sfc /scannow";
  Process.Start(newProcessInfo);
  
  newProcessInfo.Arguments = @"-Command ""sfc /scannow""";
  newProcessInfo.Arguments = @"–ExecutionPolicy Bypass -File ""c:\\Users\\HP\\Desktop\\HotelMode-PB\\HotelMode.ps1""";
  </code></pre>
  
  <p>And i need to get SID of user from another .ps1 script and then use it in this cmd command:</p>
  
  <blockquote>
    <p>HotelMode.ps1 -UserSid "" [-debug]</p>
  </blockquote>