2020-03-24 19:08:37 +01:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
2018-02-13 18:23:53 +01:00
|
|
|
// Licensed under the MIT License.
|
2017-06-22 03:53:39 +02:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Management.Automation;
|
|
|
|
|
|
|
|
namespace Application.Test
|
|
|
|
{
|
2017-10-26 23:12:19 +02:00
|
|
|
public class Program
|
2017-06-22 03:53:39 +02:00
|
|
|
{
|
|
|
|
/// <summary>
|
2019-01-06 00:40:24 +01:00
|
|
|
/// Managed entry point shim, which starts the actual program.
|
2017-06-22 03:53:39 +02: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-24 07:20:06 +01:00
|
|
|
|
2017-06-22 03:53:39 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|