GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable Windows PowerShell PSModulePath by default on Windows by SteveL-MSFT · Pull Request #4132 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Jun 28, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Now that we have moved to .Net Std 2.0 compatible CoreClr 2.0 and added capability to search GAC for assemblies, we need to make it easier for users to use Windows PowerShell modules from PSCore6 to get feedback on compatibility.

This change is only for Windows and appends the Windows PowerShell PSModulePath on startup. Depending on the data/feedback we get, we can decide what to do (opt-in vs opt-out) as we get closer to a release candidate.

Out-Default tests has to be updated to suppress the Warning message by not loading the profile.

Related #4056

Based on the customer data, we can decide a more permanent solution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT
Default powershell host profile for Windows to append Windows PowerSh…
8ff38c3
…ell PSModulePath by default to encourage testing of using FullCLR modules
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Jason Shirk (lzybkr) Jun 28, 2017
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Bruce Payette (BrucePay), Joey Aiello (joeyaiello) and Jason Shirk (lzybkr) June 28, 2017 16:20
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Jun 28, 2017
@SteveL-MSFT
Change test to use -noprofile to make output more predictable
05d723b
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) requested changes Jun 28, 2017
View reviewed changes
Comment thread build.psm1 Outdated
The currently installed .NET Command Line Tools is not the required version.

Installed version: $dotnetCLIIntalledVersion
Installed version: $dotnetCLIIntalledVersion

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Jun 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Typo in Installed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Jun 28, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

That wasn't part of this PR, but since I only see 3 hits, I'm leaning towards fixing it here instead of a new PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/powershell-win-core/Microsoft.PowerShell_profile.ps1
# If a Windows PowerShell module works or not, please provide feedback at https://github.com/PowerShell/PowerShell/issues/4062

Write-Warning "Appended Windows PowerShell PSModulePath"
$env:psmodulepath += ";${env:userprofile}\Documents\WindowsPowerShell\Modules;${env:programfiles}\WindowsPowerShell\Modules;${env:windir}\system32\WindowsPowerShell\v1.0\Modules\"

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Jun 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This only gets the default, if the Windows PSModulePath is modified by installing Azure cmdlets or SQL, then they won't be available. We would need something like this:

$env:PSModulePath += (";" + (& ${env:windir}\system32\windowspowershell\v1.0\powershell.exe '$env:PSModulePath'))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Jun 28, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Calling out to Windows PowerShell can incur a 150-250ms startup penalty. Since this change isn't intended to be the final solution and just helps to get customer feedback, I think we are ok with it not being 100% accurate. Advanced customers can update their PSModulePath as needed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jun 28, 2017

Copy link
Copy Markdown
Member Author

Although I intend for this to be temporary, I'll add a test case

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the windows-psmodulepath branch from 232f7f3 to 4f067eb Compare June 28, 2017 20:41
@SteveL-MSFT
added tests, fixed typo
1eb7b51
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the windows-psmodulepath branch from 4f067eb to 1eb7b51 Compare June 28, 2017 21:24
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) requested changes Jun 28, 2017
View reviewed changes
Comment thread build.psm1 Outdated
# copy PowerShell host profile if Windows
if ($IsWindows)
{
Copy-Item -Path "$PSScriptRoot/src/powershell-win-core/Microsoft.PowerShell_profile.ps1" -Destination $publishPath

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Jun 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

-Force ? When rebuilding without cleaning.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Jun 29, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

make sense, will add

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/powershell/engine/Module/ModulePath.Tests.ps1 Outdated

It "Default PowerShell profile appends Windows PowerShell PSModulePath only on Windows" {

$psmodulepath = & $powershell -c '$env:PSModulePath'

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Jun 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Like in this test case, would other tests now have the warning message and fail? Can you verify by running all tests?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Jun 29, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I thought I did, but hit a few more failures. Will fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lzybkr

Jason Shirk (lzybkr) commented Jun 29, 2017

Copy link
Copy Markdown
Contributor

Because this is a temporary change - can we have a temporary test that will fail at some fixed point in the future - even if it's a nightly failure, that would be fine.

The point here - if we reach that point where the test starts failing, we need to take action, either implement this correctly (not via a profile script), remove it, or something else.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
added tests, fixed typo
85b6401
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the windows-psmodulepath branch from 1eb7b51 to 85b6401 Compare June 30, 2017 17:37
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jun 30, 2017

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) rather than having a temporary test, I've changed this to not be a 'fix' but related so we'll keep the issue open and will revisit after we get some customer data

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
added -force to copy-item use
e6e064b
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Jun 30, 2017
View reviewed changes
@SteveL-MSFT
Merge branch 'windows-psmodulepath' of github.com:SteveL-MSFT/PowerSh…
68b06c5
…ell into windows-psmodulepath
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 3, 2017

Copy link
Copy Markdown
Member Author

Aditya Patwardhan (@adityapatwardhan) looks like I had some changes staged on a different computer that wasn't committed (Console Tests), can you take a quick look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Jul 3, 2017
View reviewed changes

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 3, 2017

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) can you merge so we can get this in for beta.4?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Travis Plunk (TravisEz13) and unassigned Jason Shirk (lzybkr) Jul 6, 2017
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 6, 2017

Copy link
Copy Markdown
Member Author

Travis Plunk (@TravisEz13) can you merge this since Jason Shirk (@lzybkr) is currently out of office?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Jul 7, 2017
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 7bce165 into PowerShell:master Jul 7, 2017
@alexandair

Aleksandar Nikolić (alexandair) commented Jul 17, 2017

Copy link
Copy Markdown
Contributor

This change doesn't make sense on new Nano Server container.
This is what you see when you start microsoft/nanoserver-insider-powershell:

"WARNING: Appended Windows PowerShell PSModulePath"

PS C:\> $env:psmodulepath -split ';'
PowerShell\Modules
c:\program files\powershell\Modules
C:\Users\ContainerUser\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

3 of those 5 paths are unnecessary on new Nano Server.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 17, 2017

Copy link
Copy Markdown
Member Author

Aleksandar Nikolić (@alexandair) you are correct, NanoServer-Insider doesn't have Windows PowerShell Core 5.1 anymore. Can you add a comment to #4056? The final resolution to this will likely be adding a config setting to the startup json file and checking if full windows. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the windows-psmodulepath branch July 17, 2017 15:52
@alexandair

Aleksandar Nikolić (alexandair) commented Jul 17, 2017

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MathiasMagnus

Nagy-Egri Máté Ferenc (MathiasMagnus) commented Jul 23, 2017

Copy link
Copy Markdown
Contributor

Is there a way to turn off the warning? It's fairly annoying and I can give feedback without it reminding me on every startup.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 24, 2017

Copy link
Copy Markdown
Member Author

Nagy-Egri Máté Ferenc (@MathiasMagnus) edit Microsoft.PowerShell_profile.ps1 in $PSHome and remove the Write-Warning line

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MathiasMagnus

Nagy-Egri Máté Ferenc (MathiasMagnus) commented Jul 24, 2017

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) Thanks. :)

As a sidenote: is it instructive to think that these are 1-to-1 mappings?

Powershell Bash
$PSHOME\Microsoft.PowerShell_profile.ps1 /etc/profile
$PROFILE ~/.profile
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jul 24, 2017

Copy link
Copy Markdown
Member Author

Nagy-Egri Máté Ferenc (@MathiasMagnus) yes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13 Travis Plunk (TravisEz13) mentioned this pull request Feb 13, 2018
Tests should explicitly pass -NoProfile when launching powershell. #3881
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @daxian-dbw
Add Windows PowerShell PSModulePath by default on Windows (PowerShell…
c94bb94
…#4132)

This change is only for Windows and appends the Windows PowerShell PSModulePath on startup via a default profile. Depending on the data/feedback we get, we can decide what to do (opt-in vs opt-out) as we get closer to a release candidate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) adityapatwardhan approved these changes
@joeyaiello Joey Aiello (joeyaiello) Awaiting requested review from joeyaiello
@lzybkr Jason Shirk (lzybkr) Awaiting requested review from lzybkr
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@SteveL-MSFT @lzybkr @alexandair @MathiasMagnus @daxian-dbw @adityapatwardhan @msftclas @TravisEz13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.