public static List <string> GetAllVolumeIDs() { List <string> stringList = new List <string>(); foreach (ManagementObject managementObject in WMIUtils.Query(WMIUtils.ConnectToServer("localhost", "", (string)null), "Select DeviceID From Win32_Volume")) { stringList.Add((string)managementObject["DeviceID"]); } return(stringList); }
public HyperVService(string address, NetworkCredential cred, ILogger logger, IHvServiceCallContext callContext) { this._Address = address; this._Cred = cred; this._Logger = logger; this._CallContext = callContext; this._Scope = WMIUtils.ConnectToServer(this._Address, CUtils.CombinUsernameAndDomain(this._Cred.UserName, this._Cred.Domain), this._Cred.Password, "\\root\\virtualization\\v2"); this._VirtSysMgmt = VirtualSystemManagementService.GetVirtualSystemManagmentService(this._Scope); this._SystemName = this._VirtSysMgmt.SystemName; }
public static ProcessInfo GetProcessInfo(string server, string username, string password, string processName) { ProcessInfo processInfo = (ProcessInfo)null; try { processInfo = WMIUtils.GetProcessInfo(WMIUtils.ConnectToServer(server, username, password), processName); } catch (Exception ex) { } return(processInfo); }
public static List <string> GetMSFailoverClusterNicsIDs() { List <string> stringList = new List <string>(); using (ManagementObjectCollection objectCollection = WMIUtils.Query(WMIUtils.ConnectToServer("localhost", "", (string)null), "Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")) { foreach (ManagementObject managementObject in objectCollection) { if (string.Compare((string)managementObject["ServiceName"], "Netft", true) == 0) { string str = ((string)managementObject["SettingID"]).TrimStart("{".ToCharArray()).TrimEnd("}".ToCharArray()); stringList.Add(str); } } } return(stringList); }
public static VolumeInfo GetVolumeInfo(string volumeId) { VolumeInfo volumeInfo = new VolumeInfo(); if (!volumeId.EndsWith("\\")) { volumeId += "\\"; } ManagementObject managementObject = WMIUtils.QueryFirst(WMIUtils.ConnectToServer("localhost", (string)null, (string)null), "Select * From Win32_Volume Where DeviceID='" + volumeId.Replace("\\", "\\\\") + "'"); volumeInfo.DiskSizeMB = (long)(ulong)managementObject["Capacity"] / 1048576L; volumeInfo.FreeSpaceMB = (long)(ulong)managementObject["Freespace"] / 1048576L; volumeInfo.UsedSpaceMB = volumeInfo.DiskSizeMB - volumeInfo.FreeSpaceMB; volumeInfo.Format = (string)managementObject["FileSystem"]; volumeInfo.Label = (string)managementObject["Label"]; volumeInfo.DriveType = (int)(uint)managementObject["DriveType"]; return(volumeInfo); }
public HostCfgInfo GetCfg(string address, string username, string password) { using (IVirtualSystemManagementService managmentService = VirtualSystemManagementService.GetVirtualSystemManagmentService(this._Host)) { using (IVirtualSystemManagementServiceSettingData serviceSettingData = VirtualSystemManagementServiceSettingData.GetRelated(managmentService).FirstOrDefault <IVirtualSystemManagementServiceSettingData>()) { ManagementScope server = WMIUtils.ConnectToServer(address, username, password); ManagementObject managementObject = WMIUtils.QueryFirst(server, "Select * From Win32_ComputerSystem"); return(new HostCfgInfo() { Name = this._Host.ElementName, DefaultExternalDataRoot = serviceSettingData.DefaultExternalDataRoot, DefaultVirtualHardDiskPath = serviceSettingData.DefaultVirtualHardDiskPath, CpuNum = (long)(uint)WMIUtils.GetPropertyValue((ManagementBaseObject)managementObject, "NumberOfLogicalProcessors"), Ram = (long)(ulong)WMIUtils.GetPropertyValue((ManagementBaseObject)managementObject, "TotalPhysicalMemory"), Volumes = SystemStateReader.GetVolumes(server), VirtualSwitches = this.GetAllVirtualSwitchesWithUuid().Values.Select <IVirtualSwitch, VirtualSwitchInfo>((Func <IVirtualSwitch, VirtualSwitchInfo>)(vs => vs.GetCfg())).ToList <VirtualSwitchInfo>(), OsInfo = WMIUtils.GetOperatingSystemInfo(server) }); } } }
public OperatingSystemInfo GetOS(string address, string username, string password) { using (VirtualSystemManagementService.GetVirtualSystemManagmentService(this._Host)) return(WMIUtils.GetOperatingSystemInfo(WMIUtils.ConnectToServer(address, username, password))); }
public static string GetRemoteSystemDirectory(string serverName, NetworkCredential networkCredential) { return(WMIUtils.GetSystemDirectory(WMIUtils.ConnectToServer(serverName, networkCredential.UserName, networkCredential.Password, "\\root\\cimv2"))); }
public static ManagementScope ConnectToServerDefaultPath(string serverName, string userName, string password) { return(WMIUtils.ConnectToServer(serverName, userName, password, "\\root\\default")); }
public static ManagementScope ConnectToServer(string server, NetworkCredential credentials) { string userName = CUtils.CombinUsernameAndDomain(credentials.UserName, credentials.Domain); return(WMIUtils.ConnectToServer(server, userName, credentials.Password)); }
public static ManagementScope ConnectToLocalServer() { return(WMIUtils.ConnectToServer("localhost", "", "", "\\root\\cimv2")); }
public static SystemState GetSystemState(string serverName, string userName, string password, ILogger logger) { return(SystemStateReader.GetSystemState(WMIUtils.ConnectToServer(serverName, userName, password), serverName, userName, password, logger)); }
public static bool DoesVolumeExist(uint serialNumber) { return(0 < WMIUtils.Query(WMIUtils.ConnectToServer("localhost", (string)null, (string)null), string.Format((IFormatProvider)CultureInfo.InvariantCulture, "SELECT * FROM Win32_Volume WHERE SerialNumber='{0}'", new object[1] { (object)serialNumber })).Count); }