2

I am unable to create a profile in PowerShell 7.3.2.

When I run notepad $PROFILE, the notepad prompts to create this Microsoft.PowerShell_profile.ps1 nonexistent file yet I see no file with this name in C:\Users\1999q\Documents\PowerShell.

When I run New-Item -Path $PROFILE -Type File -Force OR New-Item $PROFILE.CurrentUserCurrentHost OR

if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
}

I get the error New-Item: Could not find file 'C:\Users\1999q\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'..

Moreover, Test-Path $PROFILE gives me False.

However, $PROFILE | Get-Member -Type NoteProperty | Format-List displays the following:

TypeName   : System.String
Name       : AllUsersAllHosts
MemberType : NoteProperty
Definition : string AllUsersAllHosts=C:\Program Files\PowerShell\7\profile.ps1

TypeName   : System.String
Name       : AllUsersCurrentHost
MemberType : NoteProperty
Definition : string AllUsersCurrentHost=C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1

TypeName   : System.String
Name       : CurrentUserAllHosts
MemberType : NoteProperty
Definition : string CurrentUserAllHosts=C:\Users\1999q\Documents\PowerShell\profile.ps1

TypeName   : System.String
Name       : CurrentUserCurrentHost
MemberType : NoteProperty
Definition : string CurrentUserCurrentHost=C:\Users\1999q\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

I am unable to comprehend what exactly is going on, can anyone help me with this issue?

braX
  • 11,506
  • 5
  • 20
  • 33

1 Answers1

1

Steps to attempt

  1. Run in admin shell
    • notepad $Profile
  2. If fails, in admin shell
    • New-Item -ItemType File -Path $PROFILE -Force
    • notepad $Profile
  3. If fails (unlikely) still in admin shell
    • Set-ExecutionPolicy RemoteSigned
    • Go to step 1
ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122