Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Management;
- class TestProgram {
- public static void Main(string[] args) {
- ConnectionOptions options = new ConnectionOptions();
- options.Username = "Administrator";
- options.Password = "dRum&5853";
- options.Authentication = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), "Packet");
- options.Impersonation = (ImpersonationLevel)Enum.Parse(typeof(ImpersonationLevel), "Impersonate");
- options.Authority = "ntlmdomain:WORKGROUP";
- ManagementScope scope = new ManagementScope( "\\\\10.129.12.234\\root\\cimv2", options );
- try {
- scope.Connect();
- Console.WriteLine("Connection successful.");
- } catch (Exception e) {
- Console.WriteLine("An exception has occured!!!\n");
- Console.WriteLine(e.Message);
- System.Environment.Exit(1);
- }
- SelectQuery query = new SelectQuery( "Win32_PerfFormattedData_PerfDisk_LogicalDisk", "name IS NOT NULL" );
- ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
- try {
- ManagementObjectCollection result = searcher.Get();
- foreach( ManagementBaseObject row in result ) {
- foreach( PropertyData property in row.Properties ) {
- // Console.WriteLine(property.Name + " = " + property.Value);
- }
- }
- } catch (Exception e) {
- Console.WriteLine("An exception has occured!!!\n");
- Console.WriteLine(e.Message);
- System.Environment.Exit(1);
- }
- Main(null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement