初始化

This commit is contained in:
2025-11-21 08:48:01 +08:00
commit b4d684a84c
202 changed files with 28585 additions and 0 deletions

24
mypwsh/Program.cs Normal file
View File

@@ -0,0 +1,24 @@
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!");
}
}
}

15
mypwsh/mypwsh.csproj Normal file
View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.1" />
<PackageReference Include="System.Management.Automation" Version="7.4.12" />
</ItemGroup>
</Project>