Questions tagged [system.management]

87 questions
28
votes
2 answers

Create PSCredential without a password

How to create a instance of PSCredential that has no password? (Without manually filling out a Get-Credential dialog with no password, this is for unattended running.) Things I tried: $mycreds = New-Object System.Management.Automation.PSCredential…
LostInComputer
  • 14,252
  • 4
  • 37
  • 47
20
votes
3 answers

NullReferenceException in finalizer during MSTest

(I know, this is a ridiculously long question. I tried to separate the question from my investigation so far, so it's slightly easier to read.) I'm running my unit tests using MSTest.exe. Occasionally, I see this test error: On the individual unit…
David Yaw
  • 25,725
  • 4
  • 59
  • 90
6
votes
3 answers

System.Management.ManagementException

I am running following code: System.Management.ManagementClass wmiNetAdapterConfiguration = new System.Management.ManagementClass("Win32_NetworkAdapterConfiguration"); System.Management.ManagementObjectCollection wmiNetAdapters =…
Night Walker
  • 18,842
  • 47
  • 143
  • 217
6
votes
1 answer

ManagementObjectSearcher out of memory excepiton

In a C# .Net MVC2 app we have a simple function to get the processor id as part of a scheme to identify the web server. The relevant part is: using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select ProcessorId from…
Matthew Hood
  • 917
  • 3
  • 13
  • 22
5
votes
0 answers

ManagementObjectSearcher.Get() throws exception

When executing the following code, the searcher.Get() throws an exception "Not Supported". Even when running as admin the problem persists. This is compiled with VS 2010. The exception happens on XP, Win7 and Win8.1. Any ideas?? …
edtheprogrammerguy
  • 5,683
  • 5
  • 26
  • 45
5
votes
1 answer

C# - Powershell AddPSSnapin Causes errors

So, I import the System.Management.Automation dll and I'm trying to run a New-Mailbox command with params so I use: RunspaceConfiguration config = RunspaceConfiguration.Create(); PSSnapInException psEx =…
BRogers
  • 3,484
  • 4
  • 21
  • 28
4
votes
2 answers

Incompatible Reference: System.Management 4.0.0.0?

I created a C# 4.0 Console application. The target framework is .Net Framework 4 Client profile. I want to count the number of cores in my cpu. To do this I created the following class: internal class MultiThreading { public int…
sapbucket
  • 5,775
  • 10
  • 47
  • 85
4
votes
1 answer

How to get a list of sites and SSL certificates from IIS 6.0 using C#, WMI, and/or System.Management?

I am trying to export all the SSL certificates on IIS 6.0 sites from a specificed remote server to a centralized backup server so we can migrate and/or backup our SSL certificates, however I cannot figure out how to do this with IIS 6.0 (all our…
jvol
  • 61
  • 1
  • 3
4
votes
1 answer

C# System.Management.Automation.Powershell class leaking memory on Invoke() call

I have code for a C# test app that queries system info using PowerShell, and in it I have a few simple functions like the following: public void GetSystemInfo() { using (PowerShell ps = PowerShell.Create()) { …
8bitcartridge
  • 1,557
  • 3
  • 22
  • 37
3
votes
0 answers

System.Management.ManagementClass.GetInstances() throws exception

On different machines, we see different exceptions. One machine reports System.Runtime.InteropServices.COMException (The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)) Another reports System.BadImageFormatException ( An…
sjlewis
  • 716
  • 1
  • 11
  • 24
3
votes
1 answer

Unable to foreach through an ManagementObjectCollection, "This method is not implemented in any class" exception thrown

I am trying to query the local machine for information about the status of the different services in windows security, such as windows defender and the firewall, using WMI from system.management. For testing purposes I am working in a console…
FrederikTG
  • 41
  • 6
3
votes
1 answer

.NET Scheduled Task - WqlEventQuery to execute every 30 minutes

I am working with a POC to use the library mentioned in How to Schedule a Task In .NET Framework (C#). I got the code to work at a specific time, however How can I make it execute every 30 minutes? Below given is my Main method: static void…
3
votes
2 answers

Reference to type 'Component' claims it is defined in 'System'

Trying to get some WMI objects in a UWP application. Running VS2015 on .net 4.6. I'm getting errors for the ForEach and method calls stating "Reference to type 'Component' claims it is defined in 'System'" with error CS7069. using System; using…
Luke Griffith
  • 216
  • 4
  • 13
3
votes
1 answer

Using System.Drawing.Printing to get Queue Status

I've been trying to use System.Drawing.Printing; in order to get the queue status of a network printer. I can retrieve the properties of the printer but I can't really seem to get the queue status. This is what I've tried so far: PrinterSettings ps…
Miquel Coll
  • 729
  • 12
  • 43
3
votes
0 answers

C# System.Management.Automation.PowerShell Performance

Why is performance of executing a script from PowerShell directly much quicker than when executing the script from the System.Management.Automation.PowerShell class? When I execute my script directly in PS, it takes less than a second, though when I…
mservidio
  • 11,994
  • 8
  • 52
  • 82
1
2 3 4 5 6