Open powershell (or WindowsPowersehll) without admin author.
powershell print :
CreateFile() Error: 5
CreateFile() Error: 5
and pending until entry ctrl+c
img:

no “CreateFile() Error: 5” print
print CreateFile() Error: 5
Name Value
---- -----
PSVersion 7.0.1
PSEdition Core
GitCommitId 7.0.1
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
ps:Open cmd without admin author is no such issue.
Is powershell try creating some file in path which the current user has no write perms after every start?
If you start PowerShell with -NonInteractive is the message still printed?
Error 5 means "access denied".
It would suggest that the account does not have full read/write access to its profile directory, particularly
~\AppData\Roaming\Microsoft\Windows\PowerShell\
where psreadline tries to create its log.
procmon utility could help to find a root of the issue.
If you start PowerShell with
-NonInteractiveis the message still printed?
Error msg still here.

Error 5 means "access denied".
It would suggest that the account does not have full read/write access to its profile directory, particularly
~\AppData\Roaming\Microsoft\Windows\PowerShell
where psreadline tries to create its log.
Current user has all access for ~\AppData\Roaming\Microsoft\Windows\PowerShell.

And PSReadLine can write file for record history command in AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine normally. It seems like is not access issue of AppData\Roaming\Microsoft\Windows\PowerShell\, I konw CreateFile() Error 5 means write access issue, but would other path?

Think you.
procmon utility could help to find a root of the issue.
Thinks, I will try it.
procmon utility could help to find a root of the issue.
300+ 'CreateFile' operator which result is not 'success', nothing valuable found.
PS:Why powershell needs read or write so many files on startup? And those files are distributed everywhere (driver C, D, E,many directory seems like no relationship with powershell).
Logfile.zip
Can anyone help me?
Log file you shared is not full.
So, what should I do?
again:
Why powershell needs read or write so many files on startup? And those files are distributed everywhere (driver C, D, E,many directory seems like no relationship with powershell).
@flying1020 The issue you report is _specific_ for your system. ProcMon is better utility for diagnostic in the case. If PowerShell creates objects it creates its in user temp folder - perhaps you limited a write access to the temp folder. Also it could be a registry key.
Why powershell needs read or write so many files on startup?
You should be more concrete. By design PowerShell does nothing but the necessary.
You could look your PATH and PSModulePath environment variables - PowerShell uses its to discover modules and others.
The problem still here after re-install operator system. Could it be caused by the current user is offline account?
Thinks.
@flying1020 Do you solve this ? I have the same problem.
@wujiyoung Not yet, Is your win10 user is offline also?
Yes, it came out yesterday, while before that everything was ok.
Here is bug! no doubt.
Hi all,
Is this problem resovled ? I have same issue.
@lilyfang We need repo steps to find a root of the issue. Or you could investigate the issue locally and report what file PowerShell can not create.
Looks like each command of Powershell will reprot this error message, but the command execluted successfully.

@liyueyi You could run procmon to find the file with access denied.
@iSazonov
I guess the root cause is below event, it only occured on user process, can`t see it when i run powershell as administrator.
15:39:33.8227604 pwsh.exe 12632 CreateFile C:\Users\liyy\:docId NAME INVALID Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
15:39:33.8229056 pwsh.exe 12632 CreateFile C:\Users\liyy\:isDelay NAME INVALID Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
15:39:33.8229998 pwsh.exe 12632 CreateFile C:\Users\liyy\:status NAME INVALID Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
15:39:33.8231458 pwsh.exe 12632 CreateFile C:\Users\liyy\:isDelay NAME INVALID Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
Really basic question.
What are the environment variables homeDrive, homePath, and userprofile set to ? Is there a stray ":" in any of them ?
Really basic question.
What are the environment variables homeDrive, homePath, and userprofile set to ? Is there a stray ":" in any of them ?
No, this issue only happened in user mode powershell, therer is no error message when run powershell as administrator, i just checked user enviroment variables.
BTW, I`m not farmiliar with Windows programing, but i really thought "isDelay", "docID" looks like a function name or a variable name.
You could run pwsh -NoProfile
If the issue will still present please share get-module output and Get-Error output.
C:\Users\liyy>pwsh -NoProfile
PowerShell 7.0.3
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
CreateFile() Error: 5
CreateFile() Error: 5
CreateFile() Error: 5
CreateFile() Error: 5
CreateFile() Error: 5
CreateFile() Error: 5
CreateFile() Error: 5
PS C:\Users\liyy> CreateFile() Error: 5
CreateFile() Error: 5
PS C:\Users\liyy> Get-Module
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-It…
Script 2.0.4 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …
PS C:\Users\liyy>
What is Get-Error returns?
Have you Anaconda3 installed?
Get-Error return NULL.
I haven't installed Anaconda3.
Only suggestion is to build pwsh locally and run debugger.
:sweat:
After installed win10 2009 ,I found this issue
Finally, I disabled UAC to workaround this issue.