Skip to content

Having a network profile causes many execution policy issues #26121

@LarnuUK

Description

@LarnuUK

Prerequisites

Steps to reproduce

In my work environment, user profiles are stored on a network path, of the format \\<domain>.local\home$\<user name>. As of Powershell 7.5.3 my $profile now cannot be loaded, because the profile file isn't digitally signed.

The only way I can see to change the path for $profile is using the registry, which will impact for that just PowerShell, so isn't a solution.

I've instead tried switching to a different method, and using the following command to start PowerShell:

"C:\Program Files\PowerShell\7\pwsh.exe" -noprofile -noexit -command "invoke-expression '. ''C:\Users\<user name>\Powershell\Microsoft.PowerShell_profile.ps1''' "

This, however, doesn't properly solve the problem, as modules are still installed using the path \\<domain>.local\home$\<user name>. This means, for example, that when importing some modules i get errors such as:

Import-Module: File \.local\home$<user name>\PowerShell\Modules\Terminal-Icons\0.11.0\Terminal-Icons.psm1 cannot be loaded. The file \seib.local\Shares$\Home\tandrews\PowerShell\Modules\Terminal-Icons\0.11.0\Terminal-Icons.psm1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.

How do I change both the path the profile is stored, without a registry change that will impact other applications, and therefore ensure that my modules can be loaded.

Expected behavior

Import-Module -Name Terminal-Icons

Actual behavior

Import-Module -Name Terminal-Icons -Force
Import-Module: File \\<domain>.local\home$\<user name>\PowerShell\Modules\Terminal-Icons\0.11.0\Terminal-Icons.psm1 cannot be loaded. The file \\seib.local\Shares$\Home\tandrews\PowerShell\Modules\Terminal-Icons\0.11.0\Terminal-Icons.psm1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions