1

I'am trying to use (remote) powershell from c#.

I use :

using System.Management.Automation;
using System.Management.Automation.Runspace;

But when I try to build my app I have an error CS0234 (name does not exist in the namespace). I have added the reference of System.Management.

Which way to compile ?

Ps : I find a post where they said to add C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0 as a reference but I don't have this path...

PPs : Powershell is fully installed on my computer.

PPPs : Using win10 64 bits

3
  • have you even searched for that directory? aka the windowspowershell\1.0 Commented Sep 27, 2017 at 13:21
  • Add reference and browse...go to that path (it can be 3.0 or 1.0) and select System.Management.Automation.dll Commented Sep 27, 2017 at 13:23
  • btw that path would appear to be true for 64bit win7 ... Commented Sep 27, 2017 at 13:26

3 Answers 3

2

After searching and searching I finally find this file on my machine :

C:\windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

Which is the one for the reference.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use the Nuget package to add the references:

https://www.nuget.org/packages/Microsoft.PowerShell.5.ReferenceAssemblies/

Comments

0

Runspace is the class. Use only:

using System.Management.Automation;

And add reference to:

c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.