2020-03-24 11:08:37 -07:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
2018-02-13 09:23:53 -08:00
|
|
|
// Licensed under the MIT License.
|
2017-06-21 18:53:39 -07:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Management.Automation;
|
|
|
|
|
|
|
|
|
|
namespace Application.Test
|
|
|
|
|
{
|
2017-10-27 05:12:19 +08:00
|
|
|
public class Program
|
2017-06-21 18:53:39 -07:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-01-06 04:40:24 +05:00
|
|
|
/// Managed entry point shim, which starts the actual program.
|
2017-06-21 18:53:39 -07:00
|
|
|
/// </summary>
|
|
|
|
|
public static int Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
using (PowerShell ps = PowerShell.Create())
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\nEvaluating 'Get-Command Write-Output' in PS Core Runspace\n");
|
|
|
|
|
var results = ps.AddScript("Get-Command Write-Output").Invoke();
|
|
|
|
|
Console.WriteLine(results[0].ToString());
|
|
|
|
|
|
|
|
|
|
ps.Commands.Clear();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("\nEvaluating '([S.M.A.ActionPreference], [S.M.A.AliasAttribute]).FullName' in PS Core Runspace\n");
|
|
|
|
|
results = ps.AddScript("([System.Management.Automation.ActionPreference], [System.Management.Automation.AliasAttribute]).FullName").Invoke();
|
|
|
|
|
foreach (dynamic result in results)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(result.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-23 22:20:06 -08:00
|
|
|
|
2017-06-21 18:53:39 -07:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|