using System; using System.Management.Automation; // Windows PowerShell namespace. namespace HostPS1 { class HostPS1 { static void Main(string[] args) { // Call the PowerShell.Create() method to create an // empty pipeline. PowerShell ps = PowerShell.Create(); ps.AddCommand("Get-WmiObject"); ps.AddArgument("win32_physicalmemory"); ps.AddCommand("sort-object"); ps.AddArgument("Manufacturer"); // Call the PowerShell.Invoke() method to run the // commands of the pipeline in the default runspace. foreach (PSObject result in ps.Invoke()) { Console.WriteLine(result.Members["Manufacturer"].Value); } // End foreach. } // End Main. } // End HostPs1. }
Ejecutar el cmdlet de PowerShell para obtener información de la memoria RAM desde C# (PowerShell, Memoria, Hardware, C#)
Except where otherwise noted, Jesusninoc by Jesús N. is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.