Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ psobjects
psproxyjobs
PSReadline
PSSessionConfiguration
pwsh
redistributables
Register-EngineEvent
Register-PSSessionConfiguration
Expand Down
16 changes: 14 additions & 2 deletions assets/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<WixVariable Id="WixUIInfoIco" Value="assets\WixUIInfoIco.bmp" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open $(env.ProductName)" />
<!-- Default value of Checkbox of starting PowerShell after installation -->
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]PowerShell.exe"/>
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<UI>
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
Expand Down Expand Up @@ -73,6 +73,8 @@
<ComponentGroupRef Id="$(var.ProductVersionWithName)"/>
<ComponentRef Id="ProductVersionFolder"/>
<ComponentRef Id="ApplicationProgramsMenuShortcut"/>
<ComponentRef Id="RegistryEntries"/>
<ComponentRef Id="SetPath"/>
</Feature>
<!-- We need to show EULA, and provide option to customize download location -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
Expand Down Expand Up @@ -103,13 +105,23 @@
<Component Id="ProductVersionFolder" Guid="{e1a7f05e-0cd6-4227-80a8-e4fb311f045c}">
<CreateFolder/>
</Component>
<!-- register ourselves in application registry so can be started using just Win+R `pwsh.exe` -->
<Component Id="RegistryEntries" Guid="{402e52f7-baf8-489d-af21-f756a6ca3530}">
<RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\pwsh.exe" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
</RegistryKey>
</Component>
<!-- add ourselvs to %PATH% so pwsh.exe can be started from Windows PowerShell or cmd.exe -->
<Component Id="SetPath" Guid="{9dbb7763-7baf-48e7-b025-3bdedcb0632f}">
<Environment Id="PATH" Action="set" Name="PATH" Part="last" Permanent="no" System="yes" Value="[$(var.ProductVersionWithName)]"/>
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.ProductSemanticVersionWithName)">
<Component Id="ApplicationProgramsMenuShortcut" Guid="{A77507A7-F970-4618-AC30-20AFE36EE2EB}">
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]PowerShell.exe" WorkingDirectory="$(var.ProductVersionWithName)"
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]pwsh.exe" WorkingDirectory="$(var.ProductVersionWithName)"
Icon = "PowerShellExe.ico" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\$(var.ProductSemanticVersionWithName)\ProgramsMenuShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
Expand Down
14 changes: 7 additions & 7 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function Start-BuildNativeWindowsBinaries {
return
}

# cmake is needed to build powershell.exe
# cmake is needed to build pwsh.exe
if (-not (precheck 'cmake' $null)) {
throw 'cmake not found. Run "Start-PSBootstrap -BuildWindowsNative". You can also install it from https://chocolatey.org/packages/cmake'
}
Expand Down Expand Up @@ -497,7 +497,7 @@ Fix steps:
Start-TypeGen
}

# Get the folder path where powershell.exe is located.
# Get the folder path where pwsh.exe is located.
$publishPath = Split-Path $Options.Output -Parent
try {
# Relative paths do not work well if cwd is not changed to project
Expand All @@ -507,7 +507,7 @@ Fix steps:

if ($CrossGen) {
Start-CrossGen -PublishPath $publishPath -Runtime $script:Options.Runtime
log "PowerShell.exe with ngen binaries is available at: $($Options.Output)"
log "pwsh.exe with ngen binaries is available at: $($Options.Output)"
} else {
log "PowerShell output: $($Options.Output)"
}
Expand Down Expand Up @@ -680,9 +680,9 @@ function New-PSOptions {
}

$Executable = if ($Environment.IsLinux -or $Environment.IsMacOS) {
"powershell"
"pwsh"
} elseif ($Environment.IsWindows) {
"powershell.exe"
"pwsh.exe"
}

# Build the Output path
Expand Down Expand Up @@ -837,7 +837,7 @@ function Start-PSPester {
[string[]]$Path = @("$PSScriptRoot/test/common","$PSScriptRoot/test/powershell"),
[switch]$ThrowOnFailure,
[string]$binDir = (Split-Path (New-PSOptions).Output),
[string]$powershell = (Join-Path $binDir 'powershell'),
[string]$powershell = (Join-Path $binDir 'pwsh'),
[string]$Pester = ([IO.Path]::Combine($binDir, "Modules", "Pester")),
[Parameter(ParameterSetName='Unelevate',Mandatory=$true)]
[switch]$Unelevate,
Expand All @@ -848,7 +848,7 @@ function Start-PSPester {
[switch]$IncludeFailingTest
)

if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue))
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue))
{
Write-Warning @"
Pester module not found.
Expand Down
2 changes: 1 addition & 1 deletion demos/Raspberry-Pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ cp shared/Microsoft.NetCore.App/2.1.0-preview1-25719-04/* ~/powershell
## Start PowerShell

```bash
~/powershell/powershell
~/powershell/pwsh
```

Note that until arm32 is [fully supported by CoreCLR](https://github.com/dotnet/coreclr/issues/3977), it's not supported by PowerShell Core.
Expand Down
6 changes: 3 additions & 3 deletions demos/SSHRemoting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ In addition you will need to enable password authentication and optionally key b
```none
PasswordAuthentication yes
```
- Add a PowerShell subsystem entry, replace `c:/program files/powershell/6.0.0/powershell.exe` with the correct path to the version you want to use
- Add a PowerShell subsystem entry, replace `c:/program files/powershell/6.0.0/pwsh.exe` with the correct path to the version you want to use
```none
Subsystem powershell c:/program files/powershell/6.0.0/powershell.exe -sshs -NoLogo -NoProfile
Subsystem powershell c:/program files/powershell/6.0.0/pwsh.exe -sshs -NoLogo -NoProfile
```
- Optionally enable key authentication
```none
Expand Down Expand Up @@ -173,7 +173,7 @@ Microsoft Windows [Version 10.0.10586]
#
# Windows to Windows
#
C:\Users\PSUser\Documents>"C:\Program Files\PowerShell\6.0.0.17\powershell.exe"
C:\Users\PSUser\Documents>pwsh.exe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full path is removed here. Is this because we are putting it to %PATH%?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update the msi installer to add it to %PATH%, I wanted to remove it since it references a specific version path. I'll do the msi update separate from this PR.

PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal sealed partial class ConsoleHost
/// </param>
/// <param name = "args">
///
/// Command line parameters to powershell.exe
/// Command line parameters to pwsh.exe
///
/// </param>
/// <returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.PowerShell
{
/// <summary>
///
/// implementation of RawConsole for powershell.exe
/// implementation of RawConsole for powershell
///
/// </summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.PowerShell

/// <summary>
///
/// ConsoleHostUserInterface implements console-mode user interface for powershell.exe
/// ConsoleHostUserInterface implements console-mode user interface for powershell
///
/// </summary>
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.PowerShell
{
/// <summary>
///
/// ConsoleHostUserInterface implements console-mode user interface for powershell.exe
/// ConsoleHostUserInterface implements console-mode user interface for powershell
///
/// </summary>
internal partial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class ScheduledJobDefinition : ISerializable, IDisposable
private bool _isDisposed;

// Task Action strings.
private const string TaskExecutionPath = @"powershell.exe";
private const string TaskExecutionPath = @"pwsh.exe";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code assumes a discoverable pwsh.exe native command. Does this fix include adding pwsh.exe to the system path environment variable? If so what version? I wonder if we should allow the user to select a powershell.exe or pwsh.exe path to use for scheduled jobs (maybe in a separate issue/pr).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use Utils.DefaultPowerShellAppBase here as we do with PowerShellProcessInstance.cs to ensure the scheduled job is using the correct path.
The problem with scheduled jobs is that they can run indefinitely on a machine and if pwsh.exe is uninstalled or installed to a new location then they will break. Of course we have a similar problem with credentials expiring.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a separate PR coming for the msi installer to append to %PATH% which would also solve the Win+R->pwsh usage

If PSCore6 is uninstalled, the full path won't help either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'll do the %PATH% msi change as part of this PR as it's more useful that pwsh.exe differs form powershell.exe and I can put it at the end of the path rather than taking over the front

private const string TaskArguments = @"-NoLogo -NonInteractive -WindowStyle Hidden -Command ""Import-Module PSScheduledJob; $jobDef = [Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition]::LoadFromStore('{0}', '{1}'); $jobDef.Run()""";
private static object LockObject = new object();
private static int CurrentId = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public class PowerShellAssemblyLoadContextInitializer
/// </summary>
/// <remarks>
/// This method is to be used by native host whose TPA list doesn't include PS assemblies, such as the
/// in-box Nano powershell.exe, the PS remote WinRM plugin, in-box Nano DSC and in-box Nano SCOM agent.
/// in-box Nano powershell, the PS remote WinRM plugin, in-box Nano DSC and in-box Nano SCOM agent.
/// </remarks>
/// <param name="basePaths">
/// Base directory paths that are separated by semicolon ';'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void ProcessRecord()
/// <summary>
/// implementation for the out-default command
/// this command it implicitly inject by the
/// powershell.exe host at the end of the pipeline as the
/// powershell host at the end of the pipeline as the
/// default sink (display to console screen)
/// </summary>
[Cmdlet(VerbsData.Out, "Default", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113362", RemotingCapability = RemotingCapability.None)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,15 @@ private static bool NeedToClearProcessModulePath(string currentProcessModulePath
private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath, string personalModulePath, string sharedModulePath, string psHomeModulePath)
{
#if UNIX
const string powershellExeName = "powershell";
const string powershellExeName = "pwsh";
const string oldPowershellExeName = "powershell";
#else
const string powershellExeName = "powershell.exe";
const string powershellExeName = "pwsh.exe";
const string oldPowershellExeName = "powershell.exe";
#endif
const string powershellDepsName = "pwsh.deps.json";
const string oldPowershellDepsName = "powershell.deps.json";

StringBuilder modulePathString = new StringBuilder(currentProcessModulePath.Length);
char[] invalidPathChars = Path.GetInvalidPathChars();

Expand All @@ -791,8 +796,10 @@ private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath,
{
string parentDir = Path.GetDirectoryName(trimedPath);
string psExePath = Path.Combine(parentDir, powershellExeName);
string psDepsPath = Path.Combine(parentDir, "powershell.deps.json");
if (File.Exists(psExePath) && File.Exists(psDepsPath))
string oldExePath = Path.Combine(parentDir, oldPowershellExeName);
string psDepsPath = Path.Combine(parentDir, powershellDepsName);
string oldDepsPath = Path.Combine(parentDir, oldPowershellDepsName);
if ((File.Exists(psExePath) && File.Exists(psDepsPath)) || (File.Exists(oldExePath) && File.Exists(oldDepsPath)))
{
// Path is a PSHome module path from a different powershell core instance. Ignore it.
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace System.Management.Automation.Host
public abstract class PSHost
{
/// <summary>
/// The powershell.exe spec states that 128 is the maximum nesting depth.
/// The powershell spec states that 128 is the maximum nesting depth.
/// </summary>
internal const int MaximumNestedPromptLevel = 128;
internal static bool IsStdOutputRedirected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ static PowerShellProcessInstance()
{
#if UNIX
s_PSExePath = Path.Combine(Utils.DefaultPowerShellAppBase,
"powershell");
"pwsh");
#else
s_PSExePath = Path.Combine(Utils.DefaultPowerShellAppBase,
"powershell.exe");
"pwsh.exe");
#endif
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public PowerShellProcessInstance(Version powerShellVersion, PSCredential credent
#if CORECLR
string processArguments = " -s -NoLogo -NoProfile";
#else
// Adding Version parameter to powershell.exe
// Adding Version parameter to powershell
// Version parameter needs to go before all other parameters because the native layer looks for Version or
// PSConsoleFile parameters before parsing other parameters.
// The other parameters get parsed in the managed layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2033,11 +2033,11 @@ internal int StartSSHProcess(
}
#endif

// Create client ssh process that hosts powershell.exe as a subsystem and is configured
// Create client ssh process that hosts powershell as a subsystem and is configured
// to be in server mode for PSRP over SSHD:
// powershell -Version 5.1 -sshs -NoLogo -NoProfile
// powershell -sshs -NoLogo -NoProfile
// See sshd_configuration file, subsystems section and it will have this entry:
// Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 5.1 -sshs -NoLogo -NoProfile
// Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -sshs -NoLogo -NoProfile
string arguments;
if (!string.IsNullOrEmpty(this.KeyFilePath))
{
Expand Down Expand Up @@ -3164,6 +3164,8 @@ private void CreateContainerProcessInternal()
//
// Hyper-V container (i.e., RuntimeId is not empty) uses Hyper-V socket transport.
// Windows Server container (i.e., RuntimeId is empty) uses named pipe transport for now.
// This code executes `powershell.exe` as it exists in the container which currently is
// expected to be Windows PowerShell as it's inbox in the container.
//
cmd = string.Format(System.Globalization.CultureInfo.InvariantCulture,
@"{{""CommandLine"": ""powershell.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ internal OutOfProcessClientSessionTransportManager(Guid runspaceId,
#region Overrides

/// <summary>
/// Launch a new Process (PowerShell.exe -s) to perform remoting. This is used by *-Job cmdlets
/// Launch a new Process (pwsh -s) to perform remoting. This is used by *-Job cmdlets
/// to support background jobs without depending on WinRM (WinRM has complex requirements like
/// elevation to support local machine remoting)
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-native/Install-PowerShellRemoting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (! ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity
if ($PsCmdlet.ParameterSetName -eq "ByPath")
{
$targetPsHome = $PowerShellHome
$targetPsVersion = & "$targetPsHome\powershell" -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
$targetPsVersion = & "$targetPsHome\pwsh" -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-unix/powershell-unix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<Description>PowerShell top-level project with .NET CLI host</Description>
<AssemblyName>powershell</AssemblyName>
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>linux-x64;osx.10.12-x64;</RuntimeIdentifiers>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-win-core/powershell-win-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\PowerShell.Common.props" />
<PropertyGroup>
<Description>PowerShell Core on Windows top-level project</Description>
<AssemblyName>powershell</AssemblyName>
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
<RootNamespace>Microsoft.PowerShell</RootNamespace>
Expand Down
6 changes: 3 additions & 3 deletions test/docker/networktest/DockerRemoting.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){

# get fullpath to installed core powershell
Write-Verbose -verbose "Getting path to PowerShell core"
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\powershell.exe').fullname"
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\pwsh.exe').fullname"
if ( ! $powershellcorepath )
{
$pending = $true
Expand All @@ -40,7 +40,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
# capture the versions of full and core PowerShell
write-verbose -verbose "getting powershell full version"
$fullVersion = docker exec $client powershell -c "`$psversiontable.psversion.tostring()"
if ( ! $fullVersion )
if ( ! $fullVersion )
{
$pending = $true
write-warning "Cannot determine PowerShell full version, not running tests"
Expand All @@ -49,7 +49,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){

write-verbose -verbose "getting powershell core version"
$coreVersion = docker exec $client "$powershellcorepath" -c "`$psversiontable.psversion.tostring()"
if ( ! $coreVersion )
if ( ! $coreVersion )
{
$pending = $true
write-warning "Cannot determine PowerShell core version, not running tests"
Expand Down
4 changes: 2 additions & 2 deletions test/docker/networktest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# escape=`
FROM microsoft/windowsservercore

SHELL ["powershell.exe","-command"]
SHELL ["pwsh.exe","-command"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't break docker... there are tests in docker/tests. All tests can be can be run from windows, just run them once with the docker daemon set to windows mode and once set to Linux mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is before PSCore has been installed. So this won't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just notice this is a test file, not a production docker file.


# the source msi should change on a daily basis
# the destination should not change
Expand All @@ -18,7 +18,7 @@ RUN new-LocalUser -Name testuser -password (ConvertTo-SecureString 11aa!!AA -asp
set-item WSMan:/localhost/client/AllowUnencrypted $true; `
Start-Process -FilePath msiexec.exe -ArgumentList '-qn', `
'-i c:\PSCore.msi','-log c:\PSCore-install.log','-norestart' -wait ; `
$psexec = get-item -path ${ENV:ProgramFiles}/powershell/*/powershell.exe; `
$psexec = get-item -path ${ENV:ProgramFiles}/powershell/*/pwsh.exe; `
$corehome = $psexec.directory.fullname; `
& $psexec Install-PowerShellRemoting.ps1; `
remove-item -force c:\PSCore.msi
2 changes: 1 addition & 1 deletion test/powershell/Host/Base-Directory.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Describe "Configuration file locations" -tags "CI","Slow" {

BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "powershell"
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$profileName = "Microsoft.PowerShell_profile.ps1"
}

Expand Down
Loading