Files
Web_BLSKafka_Server_Prod/mypwsh/Program.cs
2025-11-21 08:48:01 +08:00

25 lines
657 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
namespace mypwsh
{
internal class Program
{
static void Main(string[] args)
{
using (var ps = PowerShell.Create())
{
// 避免使用 AddScript改用 AddCommand
ps.AddCommand("Get-Service");
var results = ps.Invoke();
foreach (var result in results)
{
var service = result.BaseObject;
}
}
Console.WriteLine("Hello, World!");
}
}
}