Questions tagged [system.management]

103 questions
0
votes
3 answers

Ready-to-use management-classes

I know how to gain access to management-objects. Lets say this one: var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter"); foreach (var nic in searcher.Get()) { …
Alexander Schmidt
  • 5,631
  • 4
  • 39
  • 79
0
votes
0 answers

Cannot add package to visual studio. (System.Management.Automation)

Trying to add System.Management.Automation package to my project in visual studio because I want to run powershell commands through my code, but am getting the error: The project does not support adding package references through the add package…
leon
  • 1
  • 1
0
votes
0 answers

c# - issues with powershell script

I am working on script which uses powershell to add, remove ports to the specific printer and it works really nice! App works on 4.6.2 framework and I am referencing System.Management.Automation.dll from…
piort
  • 29
  • 3
0
votes
0 answers

How do i connect to a remote computer to fetch data using VMI and C#

Im trying to make an application which connects to a remote computer using System.Management An example of my code is here. String plaintextpassword "238j93q8hfcaishfp9ah9hf3iu4nflkadsujhpg9eh97uhbngfiauefh"; SecureString securepassword =…
0
votes
0 answers

Run impersonated code along with wmi management scope [C#]

Scenario: I've a remote computer without domain with a User, called hereafter Admin. These are the steps I want to achive: Connecting to that computer Create a folder and give full control to Admin Share the created folder so can be accessed via…
user2896152
  • 762
  • 1
  • 9
  • 32
0
votes
0 answers

MarshalDirectiveException c#

I'm trying to create an impersonation of users with c#. I downloaded the System.management.dll to do it and I found a code on the Internet, but when I launch the code i found this error: System.Runtime.InteropServices.MarshalDirectiveException:…
0
votes
1 answer

How to retrieve PSComputerName from OriginInfo when returned through ps.Streams.Error.DataAdded

I am running the below code to check running for a specific running process on a remote computer, if it finds process then I can catch it in output.dataadded event and add computername to a list (processrunning), if it doesn't find it then I want to…
Darren Rose
  • 169
  • 13
0
votes
2 answers

How to fix "System.Management is supported on Windows Desktop Apps only" Exception

The Issue: Our application is a .NET 5 Windows Desktop application. The licensing capability requires the application to use the System.Management component from NuGet to create a unique device ID from the system processor ID, MAC Address and BIOS…
Jeff H
  • 157
  • 11
0
votes
0 answers

WMI with System.Management: Get files filtered by criteria and without using WQL

I am trying to get files filtered by a path and extension via WMI using System.Management with C#. I DO NOT want to use WQL (WMI Query) - (because its very slow for my purpuses) I know how to get ALL CIM_DataFile objects, but I want to filter them…
Yiftach Cohen
  • 39
  • 1
  • 4
0
votes
3 answers

How to add the reference for System.Management in VSCode?

How to add the reference for System.Management in VSCode? It always shows the error: "The type or namespace name 'Management' does not exist in the namespace 'System'" I've right clicked on System.Management and there is no option of any reference…
heinzQ
  • 23
  • 2
0
votes
0 answers

WMI win32_volume DirtyBitSet information is not showing up at every volume

I am trying to find out if there are volumes on my system that are flagged as dirty. In my approach I requested the information from the Win32_Volume class but not every drive contains information about the state of "DirtyBitSet". Am I overlooking…
0
votes
1 answer

How to iterate through BaseObject property of PSObject in C#

I have a list of PSObject items that are returned on calling the .Invoke() method while using the System.Management.Automation package. On debugging this, I can see the values of the objects that I want to print in the BaseObject and…
0
votes
1 answer

Cannot find reference for System.Management.Automation in Visual Studio (.Net Framework 4.6.2 )

So I have view this link: How to reference System.Management.Automation in a .NET Framework 4.7.2? "you must use System.Management.Automation v5.1.x." this could works for me But I want to find out if I can use System.Management.Automation without…
0
votes
1 answer

Running powershell in VB.NET - how to access the content of my variable

I am running a simple script in VB using System.Management.Automation as below Script runs fine, but how do I then access content of $offline and $online in my code after it has run? Dim scriptContents = New StringBuilder() …
Darren Rose
  • 169
  • 13
0
votes
1 answer

PowerShell Scriptblck in c#

I am trying to run a powershell script in c# that contains among other the command: Get-Credential I can run the file with the Process Command: public static void RunFile(string ps1File) { var startInfo = new…
Stephan
  • 335
  • 3
  • 12