private void BlockMachine(Kv kv) { String machineKey; BlockMachineE blockMachineE = (BlockMachineE)kv.GetInt32("BlockMachineE"); switch (blockMachineE) { case BlockMachineE.Initialized: machineKey = WmiHelper.GetMachineKey(); if (!String.IsNullOrEmpty(machineKey)) { MessageForm.Show(this, MsgE.InfoBlockMachine); kv.Set("MachineKey", machineKey); kv.Set("BlockMachine", (int)BlockMachineE.Done); } SocketClient.SendAvResponse(kv); break; case BlockMachineE.Done: machineKey = kv.Get("MachineKey"); if (!String.IsNullOrEmpty(machineKey)) { MessageForm.Show(this, MsgE.ErrorBlockMachine); } break; } }
public override CommandResult Execute(CommandResult pipeIn) { // Parameters string group = _arguments.Get <StringArgument>("Group").Value; string name = _arguments.Get <StringArgument>("Name").Value; string hostname = System.Environment.MachineName; string query = "Associators Of {{Win32_Group.Domain='{0}',Name='{1}'}} Where ResultClass = Win32_UserAccount"; if (!string.IsNullOrEmpty(group)) { query = string.Format(query, hostname, group); } else if (!string.IsNullOrEmpty(name)) { query = string.Format(query, hostname, name); } else { throw new InvalidOperationException("-Group or -Name parameter needs to be provided"); } _results = WmiHelper.ExecuteWmiQuery(query); return(_results); }
/// <summary> /// Retrieves the MAC addresses using the (old) Win32_NetworkAdapter WMI class. /// </summary> /// <returns>A list of MAC addresses.</returns> internal List <string> GetMacAddressesUsingWmi() { var values = new List <string>(); var adapters = WmiHelper.GetWMIInstances(@"root\cimv2", "Win32_NetworkAdapter", new string[] { "MACAddress", "PhysicalAdapter" }); foreach (var adapter in adapters) { try { var isPhysical = Boolean.Parse(adapter["PhysicalAdapter"] as string); if (_excludeNonPhysical && !isPhysical) { continue; } var macAddress = adapter["MACAddress"] as string; if (!string.IsNullOrEmpty(macAddress)) { values.Add(macAddress); } } catch { } } return(values); }
public override CommandResult Execute(CommandResult pipeIn) { // Obtain parameters string wmiNamespace = _arguments.Get <StringArgument>("Namespace").Value; string wmiQuery = _arguments.Get <StringArgument>("Query").Value; string wmiClass = _arguments.Get <StringArgument>("Class").Value; string wmiFilter = _arguments.Get <StringArgument>("Filter").Value; // If no query is specified, assume a class is specified if (!wmiQuery.ToUpperInvariant().Contains("SELECT")) { wmiClass = wmiQuery; } if (wmiClass != null) { wmiQuery = string.Format("Select * From {0}", wmiClass); } if (wmiFilter != null) { wmiQuery += string.Format(" Where {0}", wmiFilter); } // Remote parameters string computerName = _arguments.Get <StringArgument>("ComputerName").Value; string username = _arguments.Get <StringArgument>("Username").Value; string password = _arguments.Get <StringArgument>("Password").Value; // Execute user provided WMI query and return results to pipeline _results = WmiHelper.ExecuteWmiQuery(wmiNamespace, wmiQuery, computerName, username, password); return(_results); }
public Memory GetMemory() { try { Log.WriteStart("GetMemory"); Memory memory = new Memory(); WmiHelper wmi = new WmiHelper("root\\cimv2"); ManagementObjectCollection objOses = wmi.ExecuteQuery("SELECT * FROM Win32_OperatingSystem"); foreach (ManagementObject objOs in objOses) { memory.FreePhysicalMemoryKB = UInt64.Parse(objOs["FreePhysicalMemory"].ToString()); memory.TotalVisibleMemorySizeKB = UInt64.Parse(objOs["TotalVisibleMemorySize"].ToString()); memory.TotalVirtualMemorySizeKB = UInt64.Parse(objOs["TotalVirtualMemorySize"].ToString()); memory.FreeVirtualMemoryKB = UInt64.Parse(objOs["FreeVirtualMemory"].ToString()); } Log.WriteEnd("GetMemory"); return(memory); } catch (Exception ex) { Log.WriteError("GetMemory", ex); throw; } }
public MsDNS() { if (IsDNSInstalled()) { // creare WMI helper wmi = new WmiHelper("root\\MicrosoftDNS"); } }
public MsFTP() { if (IsInstalled()) { // instantiate WMI helper wmi = new WmiHelper("root\\MicrosoftIISv2"); } }
public static T SetPropertyValue <T>(string propertyName, object value) { var item = Activator.CreateInstance <T>(); var pInfo = typeof(T).GetProperty(propertyName); WmiHelper.SetPropertyValue(pInfo, value, item); return(item); }
public override CommandResult Execute(CommandResult pipeIn) { string computerName = _arguments.Get <StringArgument>("ComputerName").Value; string username = _arguments.Get <StringArgument>("Username").Value; string password = _arguments.Get <StringArgument>("Password").Value; _results = WmiHelper.ExecuteWmiQuery(@"ROOT\CIMV2", "Select ProcessId, Name, CommandLine From Win32_Process", computerName, username, password); return(_results); }
public bool Evaluate(Check check, IEvaluationContext context) { ManagementObjectSearcher searcher = WmiHelper.RunWmiQuery(check.Value); if (searcher.Get().Count > 0) { return(true); } return(false); }
public override CommandResult Execute(CommandResult pipeIn) { // Collect parameters for remote execution base.Execute(); string allNameArguments = _arguments.Get <StringArgument>("Name").Value; string where = string.Empty; if (!string.IsNullOrEmpty(allNameArguments)) { string[] processNames = allNameArguments.Split(','); StringBuilder whereStr = new StringBuilder(" Where ("); bool first = true; foreach (string name in processNames) { string newname = name; if (!name.ToUpperInvariant().EndsWith(".EXE")) { newname = name + ".exe"; } if (first) { whereStr.AppendFormat("(name = '{0}')", newname); first = false; } else { whereStr.AppendFormat(" or (name = '{0}')", newname); } } whereStr.Append(")"); where = whereStr.ToString(); } _results = WmiHelper.ExecuteWmiQuery("Select ProcessId, Name, CommandLine From Win32_Process" + where, computername, username, password); if (_results.Count == 0) { throw new NoPowerShellException( string.Format("Cannot find a process with the name \"{0}\". Verify the process name and call the cmdlet again.", allNameArguments) ); } return(_results); }
public override CommandResult Execute(CommandResult pipeIn) { // Collect parameters for remote execution base.Execute(); // Obtain parameters string wmiNamespace = _arguments.Get <StringArgument>("Namespace").Value; string wmiClass = _arguments.Get <StringArgument>("Class").Value; string methodName = _arguments.Get <StringArgument>("Name").Value; string methodArguments = _arguments.Get <StringArgument>("ArgumentList").Value; // Invoke WMI method _results = WmiHelper.InvokeWmiMethod(wmiNamespace, wmiClass, methodName, methodArguments, computername, username, password); return(_results); }
/// <summary> /// Gets the component value. /// </summary> /// <returns>The component value.</returns> public string GetValue() { try { var systemLogicalDiskDeviceId = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 2); var logicalDiskToPartition = Array.Find(WmiHelper.GetWMIInstances(@"root\cimv2", "Win32_LogicalDiskToPartition"), logicalDriveToPartition => (logicalDriveToPartition["Dependent"] as IDictionary <string, object>)["DeviceID"] as string == systemLogicalDiskDeviceId); var partition = Array.Find(WmiHelper.GetWMIInstances(@"root\cimv2", "Win32_DiskDriveToDiskPartition"), partition => (partition["Dependent"] as IDictionary <string, object>)["DeviceID"] as string == (logicalDiskToPartition["Antecedent"] as IDictionary <string, object>)["DeviceID"] as string); var diskdrive = Array.Find(WmiHelper.GetWMIInstances(@"root\cimv2", "Win32_DiskDrive "), diskDriveToPartition => diskDriveToPartition["DeviceID"] as string == (partition["Antecedent"] as IDictionary <string, object>)["DeviceID"] as string); return(diskdrive["SerialNumber"] as string); } catch (Exception e) { throw new DeviceIdComponentFailedToObtainValueException("Failed to GetValue() in SystemDriveSerialNumberDeviceIdComponent", e); } }
public override async Task <CollectResult> Collect() { var coll = WmiHelper.WmiQuery(Device, String.Format("SELECT * FROM Win32_LogicalDisk WHERE Name = '{0}:'", DriveLetter)); // Count usage of each OS instance (should really be only one!) decimal total = 0; decimal free = 0; int count = 0; foreach (ManagementObject queryObj in coll) { object o = queryObj["FreeSpace"]; count++; free += (decimal)Convert.ChangeType(o, typeof(decimal)); o = queryObj["Size"]; count++; total += (decimal)Convert.ChangeType(o, typeof(decimal)); } // Average them out if (count > 0) { switch (Measurement) { case DiskMeasurement.BytesFree: return(new CollectResult(free)); case DiskMeasurement.BytesUsed: return(new CollectResult(total - free)); case DiskMeasurement.MegabytesFree: return(new CollectResult(free / 1024 / 1024)); case DiskMeasurement.MegabytesUsed: return(new CollectResult((total - free) / 1024 / 1024)); case DiskMeasurement.PercentFree: return(new CollectResult((free / total) * 100)); case DiskMeasurement.PercentUsed: return(new CollectResult(1 - (free / total) * 100)); } } // Failed! throw new Exception("No disk query found!"); }
private void btnOK_Click(object sender, EventArgs e) { if (txtBanReason.Text != string.Empty) { KvUserData.UserID = this.userID; KvUserData.BanStartDate = dtpStartDate.Text; KvUserData.BanStartTime = dtpStartTime.Text; KvUserData.BanReason = txtBanReason.Text; KvUserData.BanMachineKey = WmiHelper.GetMachineKey(); if (rbDate.Checked) { KvUserData.BanEndDate = dtpEndDate.Text; KvUserData.BanEndTime = dtpEndTime.Text; } else if (rbForever.Checked) { KvUserData.BanEndDate = ""; KvUserData.BanEndTime = ""; } else if (rbDuration.Checked) { KvUserData.BanEndDate = dtServerTime.ToString(); if (cbDays.Text.Trim().Length > 0) { dtServerTime = dtServerTime.AddDays(Convert.ToInt32(cbDays.Text)); KvUserData.BanEndTime = dtServerTime.ToString(); } if (cbHours.Text.Trim().Length > 0) { dtServerTime = dtServerTime.AddHours(Convert.ToInt32(cbHours.Text)); KvUserData.BanEndTime = dtServerTime.ToString(); } } DialogResult dr = MessageForm.Confirm(this.ParentForm, MsgE.ConfirmBanUser, userName); if (dr == DialogResult.Yes) { DataSet ds = SocketClient.BanUser(KvUserData); } SubmitClicked(dr); } else { MessageForm.Error(this.ParentForm, MsgE.ErrorBanReason); } }
public override CommandResult Execute(CommandResult pipeIn) { // Obtain parameters string wmiNamespace = _arguments.Get <StringArgument>("Namespace").Value; string wmiClass = _arguments.Get <StringArgument>("Class").Value; string methodName = _arguments.Get <StringArgument>("Name").Value; string methodArguments = _arguments.Get <StringArgument>("ArgumentList").Value; // Remote parameters string computerName = _arguments.Get <StringArgument>("ComputerName").Value; string username = _arguments.Get <StringArgument>("Username").Value; string password = _arguments.Get <StringArgument>("Password").Value; _results = WmiHelper.InvokeWmiMethod(wmiNamespace, wmiClass, methodName, methodArguments, computerName, username, password); return(_results); }
public List <VersionInfo> GetVersions() { // запрос версий var windows = WmiHelper.First(WmiHelper.QueryInfo("Win32_OperatingSystem")); var bdb = getDbVersion("BaseComplex", "select max(Version) from Db_verson"); var bdb2 = getDbVersion("BaseComplex2", "select max(Version) from Db_version"); var aisurt = getAisurtVersion(); // запись результата return(new List <VersionInfo> { new VersionInfo("ОС Windows", string.Format("{0} {1}", windows["Caption"], windows["CSDVersion"])), new VersionInfo("SQL Server", DatabaseHelper.Instance.GetServerVersion(ConnectionWrapper.CreateLoginPassword(string.Empty, "master", "sa", string.Empty).ConnectionString)), new VersionInfo("АС БДБ", prepare(bdb)), new VersionInfo("АМ КЗ", prepare(bdb2)), new VersionInfo("АИС УРТ", aisurt), new VersionInfo("Aux Service", Assembly.GetExecutingAssembly().GetName().Version.ToString()) }); }
public override CommandResult Execute(CommandResult pipeIn) { string allNameArguments = _arguments.Get <StringArgument>("Name").Value; string where = string.Empty; if (!string.IsNullOrEmpty(allNameArguments)) { string[] processNames = allNameArguments.Split(','); StringBuilder whereStr = new StringBuilder(" Where ("); bool first = true; foreach (string name in processNames) { string newname = name; if (!name.ToUpperInvariant().EndsWith(".EXE")) { newname = name + ".exe"; } if (first) { whereStr.AppendFormat("(name = '{0}')", newname); first = false; } else { whereStr.AppendFormat(" or (name = '{0}')", newname); } } whereStr.Append(")"); where = whereStr.ToString(); } // Remote string computerName = _arguments.Get <StringArgument>("ComputerName").Value; string username = _arguments.Get <StringArgument>("Username").Value; string password = _arguments.Get <StringArgument>("Password").Value; _results = WmiHelper.ExecuteWmiQuery(@"ROOT\CIMV2", "Select ProcessId, Name, CommandLine From Win32_Process" + where, computerName, username, password); return(_results); }
/// <summary> /// Retrieves the MAC addresses using the CIMv2 based MSFT_NetAdapter interface (Windows 8 and up). /// </summary> /// <returns>A list of MAC addresses.</returns> internal List <string> GetMacAddressesUsingCimV2() { var values = new List <string>(); var adapters = WmiHelper.GetWMIInstances(@"root\StandardCimv2", "MSFT_NetAdapter", new string[] { "ConnectorPresent", "NdisPhysicalMedium", "PermanentAddress" }); foreach (var adapter in adapters) { try { var isPhysical = Boolean.Parse(adapter["ConnectorPresent"] as string); var ndisMedium = UInt32.Parse(adapter["NdisPhysicalMedium"] as string); // Skip non physcial adapters if instructed to do so. if (_excludeNonPhysical && !isPhysical) { continue; } // Skip wireless adapters if instructed to do so. if (_excludeWireless && ndisMedium == 9) // Native802_11 { continue; } // Add the MAC address to the list of values. var value = adapter["PermanentAddress"] as string; if (value != null) { // Ensure the hardware addresses are formatted as MAC addresses if possible. // This is a discrepancy between the MSFT_NetAdapter and Win32_NetworkAdapter interfaces. value = FormatMacAddress(value); values.Add(value); } } catch { } } return(values); }
//_________________________________________________________________________________________________ //_________________________________________________________________________________________________ protected void myWorker1_DoWork(object sender, DoWorkEventArgs e) { changes = false; BackgroundWorker sendingWorker = (BackgroundWorker)sender; //Capture the BackgroundWorker that fired the event FIMServer FIMSrv = (FIMServer)e.Argument; //Collect the array of objects the we recived from the main thread int maxValue = (int)FIMSrv.num; //Get the numeric value from inside the objects array, don't forget to cast StringBuilder sb = new StringBuilder(); //Declare a new string builder to store the result. // Conect to servers string sMsg = "Connecting " + FIMSrv.label + ": " + WmiHelper.ConnectServer(FIMSrv); sb.Append(string.Format("{0}{1}", sMsg, Environment.NewLine)); Log(sb.ToString()); ResultProfile result = new ResultProfile(); result.r = "success"; // Clear logs WmiHelper.ClearRuns(FIMSrv); // Execute profiles for (int i = 1; i <= maxValue && result.r == "success"; i++) //Start a for loop { if (!sendingWorker.CancellationPending) //At each iteration of the loop, check if there is a cancellation request pending { result = PerformHeavyOperation(FIMSrv); sMsg = Environment.NewLine + "Result: " + FIMSrv.label + " [" + FIMSrv.lastRun + "]: " + result.r + result.desc + Environment.NewLine; //if (sMsg.Contains("error")) e.Result = "Error"; sb.Append(sMsg); //Append the result to the string builder sendingWorker.ReportProgress(i); //Report our progress to the main thread Log(sb.ToString(), result.changes); System.Threading.Tasks.Task.Delay(5000); } else { e.Cancel = true; //If a cancellation request is pending,assgine this flag a value of true break; // If a cancellation request is pending, break to exit the loop } changes |= (result.changes > 0); } e.Result = sb.ToString();// Send our result to the main thread! }
public void RebootSystem() { try { Log.WriteStart("RebootSystem"); WmiHelper wmi = new WmiHelper("root\\cimv2"); ManagementObjectCollection objOses = wmi.ExecuteQuery("SELECT * FROM Win32_OperatingSystem"); foreach (ManagementObject objOs in objOses) { objOs.Scope.Options.EnablePrivileges = true; objOs.InvokeMethod("Reboot", null); } Log.WriteEnd("RebootSystem"); } catch (Exception ex) { Log.WriteError("RebootSystem", ex); throw; } }
public override CommandResult Execute(CommandResult pipeIn) { bool all = _arguments.Get <BoolArgument>("All").Value; string simpleSelect = "Description, IPAddress, DefaultIPGateway"; string allSelect = simpleSelect + ", DNSServerSearchOrder"; string query = "Select {0} From Win32_NetworkAdapterConfiguration {1}"; if (all) { query = string.Format(query, allSelect, string.Empty); } else { query = string.Format(query, simpleSelect, "Where IPEnabled = 'True'"); } _results = WmiHelper.ExecuteWmiQuery(query); return(_results); }
/// <summary> /// Gets the component value. /// </summary> /// <returns>The component value.</returns> public string GetValue() { var values = new List <string>(); foreach (var obj in WmiHelper.GetWMIInstances(@"root\cimv2", _wmiClass)) { try { values.Add(((IDictionary <string, object>)obj)[_wmiProperty].ToString()); } catch { } } values.Sort(); return((values != null && values.Count > 0) ? string.Join(",", values.ToArray()) : null); }
public WindowsProcess[] GetWindowsProcesses() { try { Log.WriteStart("GetWindowsProcesses"); List <WindowsProcess> winProcesses = new List <WindowsProcess>(); WmiHelper wmi = new WmiHelper("root\\cimv2"); ManagementObjectCollection objProcesses = wmi.ExecuteQuery( "SELECT * FROM Win32_Process"); foreach (ManagementObject objProcess in objProcesses) { int pid = Int32.Parse(objProcess["ProcessID"].ToString()); string name = objProcess["Name"].ToString(); // get user info string[] methodParams = new String[2]; objProcess.InvokeMethod("GetOwner", (object[])methodParams); string username = methodParams[0]; WindowsProcess winProcess = new WindowsProcess(); winProcess.Pid = pid; winProcess.Name = name; winProcess.Username = username; winProcess.MemUsage = Int64.Parse(objProcess["WorkingSetSize"].ToString()); winProcesses.Add(winProcess); } Log.WriteEnd("GetWindowsProcesses"); return(winProcesses.ToArray()); } catch (Exception ex) { Log.WriteError("GetWindowsProcesses", ex); throw; } }
public override CommandResult Execute(CommandResult pipeIn) { // Collect parameters for remote execution base.Execute(); CommandResult wmiHotfixes = WmiHelper.ExecuteWmiQuery("Select CSName,Description,HotFixID,InstalledBy,InstalledOn From Win32_QuickFixEngineering", computername, username, password); foreach (ResultRecord hotfix in wmiHotfixes) { _results.Add( new ResultRecord() { { "Source", hotfix["CSName"] }, { "Description", hotfix["Description"] }, { "HotFixID", hotfix["HotFixID"] }, { "InstalledBy", hotfix["InstalledBy"] }, { "InstalledOn", hotfix["InstalledOn"] } } ); } return(_results); }
public override async Task <CollectResult> Collect() { var coll = WmiHelper.WmiQuery(Device, "SELECT * FROM Win32_PerfFormattedData_PerfOS_System"); // Count usage of each OS instance (should really be only one!) decimal total = 0; int count = 0; foreach (ManagementObject queryObj in coll) { object o = queryObj["FileDataOperationsPersec"]; count++; total += (decimal)Convert.ChangeType(o, typeof(decimal)); } // Average them out if (count > 0) { return(new CollectResult(total / count)); } // Failed! throw new Exception("No disk query found!"); }
public override CommandResult Execute(CommandResult pipeIn) { string name = _arguments.Get <StringArgument>("Name").Value; string sid = _arguments.Get <StringArgument>("SID").Value; string query = "Select Name, Description, Disabled{0} From Win32_UserAccount Where LocalAccount='True'{1}"; if (!string.IsNullOrEmpty(name)) { query = string.Format(query, ", SID", string.Format(" And Name='{0}'", name)); } else if (!string.IsNullOrEmpty(sid)) { query = string.Format(query, ", SID", string.Format(" And SID='{0}'", sid)); } else { query = string.Format(query, string.Empty, string.Empty); } _results = WmiHelper.ExecuteWmiQuery(query); return(_results); }
public override CommandResult Execute(CommandResult pipeIn) { bool simple = _arguments.Get <BoolArgument>("Simple").Value; ResultRecord wmiOS = WmiHelper.ExecuteWmiQuery("Select * From Win32_OperatingSystem")[0]; ResultRecord wmiCS = WmiHelper.ExecuteWmiQuery("Select * From Win32_ComputerSystem")[0]; // OS Version string strOsVersion = string.Format("{0} Build {1}", wmiOS["Version"], /* wmiInfo["CSDVersion"],*/ // TODO wmiOS["BuildNumber"]); // Original Install Date string sOrigInstallDate = null; Match dateMatch = MatchDate(wmiOS, "InstallDate"); if (dateMatch != null) { sOrigInstallDate = string.Format("{0}-{1}-{2}, {3}:{4}:{5}", dateMatch.Groups[3], dateMatch.Groups[2], dateMatch.Groups[1], dateMatch.Groups[4], dateMatch.Groups[5], dateMatch.Groups[6]); } // System Boot Time string sSystemBootTime = null; dateMatch = MatchDate(wmiOS, "LastBootUpTime"); if (dateMatch != null) { sSystemBootTime = string.Format("{0}-{1}-{2}, {3}:{4}:{5}", dateMatch.Groups[3], dateMatch.Groups[2], dateMatch.Groups[1], dateMatch.Groups[4], dateMatch.Groups[5], dateMatch.Groups[6]); } // Processors CommandResult wmiCPUs = WmiHelper.ExecuteWmiQuery("Select * From Win32_Processor"); List <string> cpus = new List <string>(wmiCPUs.Count); foreach (ResultRecord cpu in wmiCPUs) { cpus.Add(string.Format("{0} ~{1} Mhz", cpu["Description"], cpu["CurrentClockSpeed"])); } // Bios string strBiosVersion = null; ResultRecord wmiBios = WmiHelper.ExecuteWmiQuery("Select * From Win32_BIOS")[0]; dateMatch = MatchDate(wmiBios, "ReleaseDate"); if (dateMatch != null) { strBiosVersion = string.Format("{0} {1}, {2}-{3}-{4}", wmiBios["Manufacturer"], wmiBios["SMBIOSBIOSVersion"], dateMatch.Groups[3], dateMatch.Groups[2], dateMatch.Groups[1]); } // Hotfixes List <string> hotfixes = new List <string>() { "[unlisted]" }; if (!simple) { CommandResult wmiHotfixes = WmiHelper.ExecuteWmiQuery("Select HotFixID From Win32_QuickFixEngineering"); hotfixes = new List <string>(wmiHotfixes.Count); foreach (ResultRecord hotfix in wmiHotfixes) { hotfixes.Add(hotfix["HotFixID"]); } } // Time zone int timeZone = Convert.ToInt32(wmiOS["CurrentTimeZone"]) / 60; string sTimeZone = string.Format("UTC{0}{1}", timeZone > 0 ? "+" : "-", timeZone); // Pagefile string sPageFile = WmiHelper.ExecuteWmiQuery("Select Name From Win32_PageFileUsage")[0]["Name"]; // Summarize information _results.Add( new ResultRecord() { { "Host Name", wmiOS["CSName"] }, { "OS Name", wmiOS["Caption"] }, { "OS Version", strOsVersion }, { "OS Manufacturer", wmiOS["Manufacturer"] }, { "OS Build Type", wmiOS["BuildType"] }, { "Registered Owner", wmiOS["RegisteredUser"] }, { "Registered Organization", wmiOS["Organization"] }, { "Product ID", wmiOS["SerialNumber"] }, { "Original Install Date", sOrigInstallDate }, { "System Boot Time", sSystemBootTime }, { "System Manufacturer", wmiCS["Manufacturer"] }, { "System Model", wmiCS["Model"] }, { "System Type", wmiCS["SystemType"] }, { "Processor(s)", string.Join(", ", cpus.ToArray()) }, { "BIOS Version", strBiosVersion }, { "Windows Directory", wmiOS["WindowsDirectory"] }, { "System Directory", wmiOS["SystemDirectory"] }, { "Boot Device", wmiOS["BootDevice"] }, { "System Locale", wmiOS["OSLanguage"] }, { "Input Locale", wmiOS["OSLanguage"] }, // TODO { "Time Zone", sTimeZone }, // TODO { "Total Physical Memory", wmiOS["TotalVisibleMemorySize"] }, { "Available Physical Memory", wmiOS["FreePhysicalMemory"] }, { "Virtual Memory: Max Size", wmiOS["TotalVirtualMemorySize"] }, { "Virtual Memory: Available", wmiOS["FreeVirtualMemory"] }, { "Virtual Memory: In Use", "[not implemented]" }, // TODO { "Page File Location(s)", sPageFile }, { "Domain", wmiCS["Domain"] }, { "Logon Server", Environment.GetEnvironmentVariable("LOGONSERVER") }, { "Hotfix(s)", string.Join(", ", hotfixes.ToArray()) }, { "Network Card(s)", "[not implemented]" }, // TODO { "Hyper-V Requirements", "[not implemented]" } // TODO } ); return(_results); }
public override CommandResult Execute(CommandResult pipeIn) { _results = WmiHelper.ExecuteWmiQuery("Select Caption, Description, Destination, Mask, NextHop From Win32_IP4RouteTable"); return(_results); }
// Gets the Dictionary of HostNames associated with the application <"HostName", "Whether the host is assocated with dynamic send port (true/false)"> public static Dictionary <string, bool> GetHostNamesWithAsAResultOfDynamicPort(this Application application) { //Dictionary<'Host Name', 'Is Dynamic port host'> Dictionary <string, bool> hostNames = new Dictionary <string, bool>(); string hostName = ""; //OurStopWatch.Enter("List host associated with all receive locations"); //List host associated with all receive locations foreach (ReceivePort item in application.ReceivePorts) { foreach (Microsoft.BizTalk.ExplorerOM.ReceiveLocation itemLoc in item.ReceiveLocations) { if (itemLoc.ReceiveHandler.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString()) { hostName = itemLoc.ReceiveHandler.Host.Name; } if (!hostNames.ContainsKey(hostName)) { hostNames.Add(hostName, false); } } } //OurStopWatch.Exit(); //OurStopWatch.Enter("List host associated with all orchestrations"); //List host associated with all orchestrations foreach (BtsOrchestration item in application.Orchestrations) { if (item.Host != null) { if (item.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString()) { hostName = item.Host.Name; } } if (!hostNames.ContainsKey(hostName)) { hostNames.Add(hostName, false); } } //OurStopWatch.Exit(); //OurStopWatch.Enter("List host associated with all send ports (Non dynamic)"); //List host associated with all send ports (Non dynamic) foreach (Microsoft.BizTalk.ExplorerOM.SendPort item in application.SendPorts) { if (!item.IsDynamic) { if (item.PrimaryTransport.SendHandler.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString()) { hostName = item.PrimaryTransport.SendHandler.Name; } } if (!hostNames.ContainsKey(hostName)) { hostNames.Add(hostName, false); } } //OurStopWatch.Exit(); //OurStopWatch.Enter("List all host if dynamic send port present"); //List all host if dynamic send port present foreach (Microsoft.BizTalk.ExplorerOM.SendPort item in application.SendPorts) { if (item.IsDynamic) { //foreach (string hostNameDynamic in MSBTS_Host.GetAllInProcessHosts()) //{ // if (!hostNames.ContainsKey(hostNameDynamic)) // { // hostNames.Add(hostNameDynamic, item.IsDynamic); // } //} foreach (string hostNameDynamic in WmiHelper.GetSendHandlerHosts()) { if (!hostNames.ContainsKey(hostNameDynamic)) { hostNames.Add(hostNameDynamic, true); } } break; } } //OurStopWatch.Exit(); return(hostNames); }