PS v7 can't find part of path of statement in profile?

4 views
Skip to first unread message

Mike Leone

unread,
Jan 23, 2026, 3:17:56 PMJan 23
to NTPowershell Mailing List
Has anyone seen this? I installed PS v7. I made a copy of my PS profile I use i v5, and saved it. But when I start v7, I get this error:

PowerShell 7.5.4
Set-ExecutionPolicy: \\nt_san1\users\MJL-Priv\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:1
Line |
   1 |  Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy BYPASS -Force
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Could not find a part of the path '\\nt_san1\users\MJL-Priv\Documents\PowerShell\powershell.config.json'.

This is correct, as I don't have any file with that name, at that location. But why would I have one? I don't have one in v5, and this command does not throw an error.

Doesn't matter if I use -Force or not.

I haven't found any solution or cause, while searching. Anyone have any idea?
--

Mike. Leone, <mailto:tur...@mike-leone.com>

PGP Fingerprint: 0AA8 DC47 CB63 AE3F C739 6BF9 9AB4 1EF6 5AA5 BCDF
Photo Gallery: <http://www.flickr.com/photos/mikeleonephotos>

Solodow, Damien

unread,
Jan 23, 2026, 3:23:19 PMJan 23
to ntpowe...@googlegroups.com

Does your profile reference $profile or $profile.currentusercurrenthost ?

 

Gaylor Electric logo

Facebook logo

Instagram logo

LinkedIn logo

X logo

YouTube logo

Damien Solodow
IT Senior Systems Engineer
Gaylor Electric, Inc.
10405 Crosspoint Blvd
Indianapolis, IN. 46256
O: 317.815.3103 | M: 317.506.8521

--
You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ntpowershell/CAHBr%2B%2Bin0fFxfhBsuFoSjfgx9bp4Uuwk-b%3D887JC_jLb9zEKsw%40mail.gmail.com.

Mike Leone

unread,
Jan 23, 2026, 3:37:31 PMJan 23
to ntpowe...@googlegroups.com
On Fri, Jan 23, 2026 at 3:23 PM Solodow, Damien <dsol...@gaylor.com> wrote:

Does your profile reference $profile or $profile.currentusercurrenthost ?


No.

 This is my profile:

============================================================
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy BYPASS -Force
Write-Host "This here is the profile for Powershell  v. "$PSVersionTable.PSVersion.Major

# Connect to local repository, so that we can load modules, in case they are not installed locally
$LocalRepoLocation = "\\DC1FIL020\netadmin\PHA_PS_Internal_Repository"
$LocalRepoName     = "PHA Internal PSRepository"
$NuGetLocation = "\\DC1FIL020\netadmin\PHA_PS_Internal_Repository\nuget"
$LocalNuGetLocation = "C:\Program Files\PackageManagement\ProviderAssemblies"

 Write-Host -ForegroundColor Green "Checking PHA Internal PSRepository registered .."  -NoNewLine
IF ((Get-PSRepository | Where {$_ -match "Internal"} ) -eq $null ) {
        Write-Host -fore Green "---- Internal Repository not present"
Write-Host -ForegroundColor Green "Copying, then Installing PackageProvider"
$FileExists = Test-Path $LocalNuGetLocation
IF ($FileExists -NE $True) {
Write-Host -ForegroundColor Green "Copying over the NuGet files"
Copy-Item -Path $NuGetLocation -Recurse -Destination $LocalNuGetLocation -Container
}
Import-PackageProvider -Name NuGet -RequiredVersion 2.855.208
Write-Host -ForegroundColor Green "Registering PSRepository"
        Register-PSRepository -Name $LocalRepoName -SourceLocation $LocalRepoLocation -InstallationPolicy Trusted
} ELSE {
       Write-Host -ForegroundColor Green "Internal PHA PSRepository already installed and configured"
}


Import-Module -Name ActiveDirectory
==================================================

Yes, I like status messages in color. LOL

Solodow, Damien

unread,
Jan 23, 2026, 3:52:24 PMJan 23
to ntpowe...@googlegroups.com

Wow, Friday brain strikes. The relevant part of the error is “powershell.config.json”; it’s trying to write that file to store your CurrentUser scoped ExecutionPolicy.

This is a change from Windows PowerShell (aka 5.1) which stored those settings in the registry.

 

Try this:

test-path (split-path $profile.CurrentUserCurrentHost)

 

Betting that will be false, and if you create said directory (and make sure you can write to it) the error will vanish.

 

about_PowerShell_Config - PowerShell | Microsoft Learn

Mike Leone

unread,
Jan 27, 2026, 3:18:15 PMJan 27
to ntpowe...@googlegroups.com
On Fri, Jan 23, 2026 at 3:52 PM Solodow, Damien <dsol...@gaylor.com> wrote:

Wow, Friday brain strikes. The relevant part of the error is “powershell.config.json”; it’s trying to write that file to store your CurrentUser scoped ExecutionPolicy.

This is a change from Windows PowerShell (aka 5.1) which stored those settings in the registry.

 

Try this:

test-path (split-path $profile.CurrentUserCurrentHost)

 

Betting that will be false,


You'd lose that bet ...

PS P:\software\PHA Scripts> test-path (split-path $profile.CurrentUserCurrentHost)
True
PS P:\software\PHA Scripts>  $profile.CurrentUserCurrentHost
\\nt_san1\users\MJL-Priv\Documents\PowerShell\Microsoft.PowerShell_profile.ps1dir 

PS P:\software\PHA Scripts> dir \\nt_san1\users\MJL-Priv\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

    Directory: \\nt_san1\users\MJL-Priv\Documents\PowerShell

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           1/27/2026 12:44 PM           5009 Microsoft.PowerShell_profile.ps1

I can't create that file ...

PS P:\software\PHA Scripts> New-Item -ItemType File -Path " \\nt_san1\users\MJL-Priv\Documents\PowerShell\powershell.config.json"
New-Item: Could not find a part of the path 'P:\software\PHA Scripts\ \nt_san1\users\MJL-Priv\Documents\PowerShell\powershell.config.json'.

Notice the weird path in the error msg; that's not what I typed in the "New-Item" command.
It's sticking a "P:\software\PHA Scripts" in front of the path I typed. That's the home of the script; it's not the location of the JSON it is trying to read, and that I am trying to create.

I can't create a file in there, even from a command prompt:

Z:\Documents\PowerShell>copy con test-file.txt
Test
The system cannot find the path specified.
        0 file(s) copied.

Yet, my account has the access:

image.png




Solodow, Damien

unread,
Jan 27, 2026, 3:22:16 PMJan 27
to ntpowe...@googlegroups.com

You don’t have Controlled Folder Access enabled do you?

 

Gaylor Electric logo

Facebook logo

Instagram logo

LinkedIn logo

X logo

YouTube logo

Damien Solodow
IT Senior Systems Engineer
Gaylor Electric, Inc.
10405 Crosspoint Blvd
Indianapolis, IN. 46256
O: 317.815.3103 | M: 317.506.8521

 

From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Mike Leone
Sent: Tuesday, January 27, 2026 3:18 PM
To: ntpowe...@googlegroups.com
Subject: Re: [ntpowershell] PS v7 can't find part of path of statement in profile?

 

 

 

On Fri, Jan 23, 2026 at 3:52PM Solodow, Damien <dsol...@gaylor.com> wrote:

Mike Leone

unread,
Jan 27, 2026, 3:23:03 PMJan 27
to ntpowe...@googlegroups.com
On Tue, Jan 27, 2026 at 3:22 PM Solodow, Damien <dsol...@gaylor.com> wrote:

You don’t have Controlled Folder Access enabled do you?


Never even heard of it, so ... no? LOL

Mike Leone

unread,
Jan 27, 2026, 3:23:56 PMJan 27
to ntpowe...@googlegroups.com
Also, we don't use MS Defender, we use BitDefender.

Solodow, Damien

unread,
Jan 27, 2026, 3:49:42 PMJan 27
to ntpowe...@googlegroups.com

Are you able to save/create/copy a powershell.config.json file to \\nt_san1\users\MJL-Priv\Documents\PowerShell\ ?

 

The content you’d need for your execution policy is

{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}

 

Gaylor Electric logo

Facebook logo

Instagram logo

LinkedIn logo

X logo

YouTube logo

Damien Solodow
IT Senior Systems Engineer
Gaylor Electric, Inc.
10405 Crosspoint Blvd
Indianapolis, IN. 46256
O: 317.815.3103 | M: 317.506.8521

 

From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Mike Leone
Sent: Tuesday, January 27, 2026 3:24 PM
To: ntpowe...@googlegroups.com
Subject: Re: [ntpowershell] PS v7 can't find part of path of statement in profile?

 

Also, we don't use MS Defender, we use BitDefender.

--

You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.

Mike Leone

unread,
Jan 27, 2026, 3:59:09 PMJan 27
to ntpowe...@googlegroups.com
On Tue, Jan 27, 2026 at 3:49 PM Solodow, Damien <dsol...@gaylor.com> wrote:

Are you able to save/create/copy a powershell.config.json file to \\nt_san1\users\MJL-Priv\Documents\PowerShell\ ?


Apparently not ...
 

The content you’d need for your execution policy is

{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}


I'll look more into it tomorrow.
 

Solodow, Damien

unread,
Jan 27, 2026, 4:08:31 PMJan 27
to ntpowe...@googlegroups.com

👍🏻

Once you can create/edit that file in that path, your error will go away. 😊

Mike Leone

unread,
Jan 28, 2026, 8:33:40 AMJan 28
to ntpowe...@googlegroups.com
I believe now my issue must be related to my either my anti-malware software (BitDefender), or a GPO perhaps. If I log in with the exact same account, to a different VM, I do not get that error. The file is created, and has the content specified.

If I log in to my usual VM, I get that error message. I'll see if I can find the time to dig into it later today ...

Meanwhile, as a weird workaround, I can edit my profile and such on the testing VM, then I can start PS in my usual VM the way I need it ...

Always something ....

Reply all
Reply to author
Forward
0 new messages