diff --git a/src/System.Management.Automation/System.Management.Automation.csproj b/src/System.Management.Automation/System.Management.Automation.csproj index 676781b7707..2c8fec76813 100644 --- a/src/System.Management.Automation/System.Management.Automation.csproj +++ b/src/System.Management.Automation/System.Management.Automation.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/src/powershell-unix/powershell-unix.csproj b/src/powershell-unix/powershell-unix.csproj index 3d59eb197b7..f6b16e80d70 100644 --- a/src/powershell-unix/powershell-unix.csproj +++ b/src/powershell-unix/powershell-unix.csproj @@ -31,8 +31,6 @@ - - diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 2e36ddb1478..49e815b2e21 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -24,10 +24,10 @@ PreserveNewest PreserveNewest - - preview\pwsh-preview.cmd - PreserveNewest - + + preview\pwsh-preview.cmd + PreserveNewest + @@ -40,7 +40,6 @@ - diff --git a/test/hosting/NuGet.Config b/test/hosting/NuGet.Config index c2c6e1b7c2d..c7d76968986 100644 --- a/test/hosting/NuGet.Config +++ b/test/hosting/NuGet.Config @@ -2,7 +2,6 @@ - diff --git a/test/hosting/hosting.tests.csproj b/test/hosting/hosting.tests.csproj index dfe9a9706fa..a63fe941a90 100644 --- a/test/hosting/hosting.tests.csproj +++ b/test/hosting/hosting.tests.csproj @@ -18,7 +18,9 @@ - + + + diff --git a/test/hosting/test_HostingBasic.cs b/test/hosting/test_HostingBasic.cs index 90fb8c2f28a..164f1f02aae 100644 --- a/test/hosting/test_HostingBasic.cs +++ b/test/hosting/test_HostingBasic.cs @@ -1,9 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Xunit; using System; +using System.IO; using System.Management.Automation; +using System.Security; +using Microsoft.Management.Infrastructure; +using Xunit; namespace PowerShell.Hosting.SDK.Tests { @@ -51,5 +54,90 @@ public static void TestCommandFromCore() } } } + + [SkippableFact] + public static void TestCommandFromMMI() + { + // Test is disabled since we do not have a CimCmdlets module released in the SDK. + Skip.IfNot(Platform.IsWindows); + using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) + { + var results = ps.AddScript("[Microsoft.Management.Infrastructure.CimInstance]::new('Win32_Process')").Invoke(); + Assert.True(results.Count > 0); + } + } + + [SkippableFact] + public static void TestCommandFromDiagnostics() + { + Skip.IfNot(Platform.IsWindows); + using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) + { + var results = ps.AddScript("Get-WinEvent -ListLog Application").Invoke(); + + foreach (dynamic item in results) + { + Assert.Equal("Application", item.LogName); + } + } + } + + [SkippableFact] + public static void TestCommandFromSecurity() + { + Skip.IfNot(Platform.IsWindows); + using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) + { + var results = ps.AddScript("ConvertTo-SecureString -String test -AsPlainText -Force").Invoke(); + Assert.IsType(results[0]); + } + } + + [SkippableFact] + public static void TestCommandFromWSMan() + { + Skip.IfNot(Platform.IsWindows); + using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) + { + var results = ps.AddScript("Test-WSMan").Invoke(); + + foreach (dynamic item in results) + { + Assert.Equal("Microsoft Corporation", item.ProductVendor); + } + } + } + + [Fact] + public static void TestCommandFromNative() + { + var fs = File.Create(Path.GetTempFileName()); + fs.Close(); + + string target = fs.Name; + string path = Path.GetTempFileName(); + + using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) + { + // New-Item -ItemType SymbolicLink uses libpsl-native, hence using it for validating native dependencies. + string command = $"New-Item -ItemType SymbolicLink -Path {path} -Target {target}"; + var results = ps.AddScript(command).Invoke(); + + foreach (var item in results) + { + Assert.Equal(path, item.FullName); + } + } + + if (File.Exists(path)) + { + File.Delete(path); + } + + if (File.Exists(target)) + { + File.Delete(target); + } + } } }