Closed skrabbe001 closed 1 month ago
I just created the PowerShell directory and even when all the folders in the path exists, the command still fails.
PS C:\Windows\System32> echo $profile
C:\Users\JohnSmith\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Windows\System32> Get-Item "C:\Users\JohnSmith\Documents\PowerShell"
Directory: C:\Users\JohnSmith\Documents
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/4/2024 12:23 PM PowerShell
PS C:\Windows\System32> New-Item -Path "C:\Users\JohnSmith\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" -ItemType "File" -Force
New-Item: Could not find file 'C:\Users\JohnSmith\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'.
Tested both as admin and as current user.
Here are the access rights to the folder:
PS C:\Windows\System32> get-acl "C:\Users\JohnSmith\Documents\PowerShell"
Directory: C:\Users\JohnSmith\Documents
Path Owner Access
---- ----- ------
PowerShell AzureAD\skrabbe001 NT AUTHORITY\SYSTEM Allow FullControl…
PS C:\Windows\System32> (get-acl "C:\Users\JohnSmith\Documents\PowerShell").Access
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : NT AUTHORITY\SYSTEM
IsInherited : True
InheritanceFlags : ContainerInherit, ObjectInherit
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited : True
InheritanceFlags : ContainerInherit, ObjectInherit
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : AzureAD\JohnSmith
IsInherited : True
InheritanceFlags : ContainerInherit, ObjectInherit
PropagationFlags : None
Note that creating files in the folder with CMD.EXE or EXPLORER.EXE works fine.
This repository is for documentation. You seem to be looking for support, which we can't provide here.
I suggest you try posting your issue with context in one of the available community support forums.
So if the command in your doc does not work, its not a doc issue?
Type of issue
Code doesn't work
Feedback
The command for creating a profile does not work, when the PowerShell directory does not exist, which it does not when installing the current version of PowerShell:
Why does it not work?
Page URL
https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/creating-profiles?view=powershell-7.4
Content source URL
https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/docs-conceptual/learn/shell/creating-profiles.md
Author
@sdwheeler
Document Id
c3b21d50-9ab5-ad3c-316a-330a460a5dd0