System files in File Explorer showing up on desktop

C:\Users\daver>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NoExit
Windows PowerShell terminated with the following error:
The type initializer for 'System.Management.Automation.Utils' threw an exception.

Step 4 test did not show any of the code listed
 

Thanks, davercrb2. Since PowerShell fails even with:
-NoProfile
this is not a PowerShell profile script problem.
Given that your Desktop registry value was missing earlier, I now suspect your user shell folder registry values may have more missing/corrupted entries, especially Documents, AppData, or Local AppData. Windows PowerShell uses those very early during startup.

Step 1: Back up the affected registry keys​

Open Command Prompt and run these two commands:
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "%USERPROFILE%\Desktop\UserShellFolders-backup.reg" /y
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "%USERPROFILE%\Desktop\ShellFolders-backup.reg" /y
If either export says the key was not found, let me know, but continue.

Step 2: Recreate key user folder paths​

Run these commands one at a time in Command Prompt:
mkdir "%USERPROFILE%\Documents"
mkdir "%USERPROFILE%\AppData\Local"
mkdir "%USERPROFILE%\AppData\Roaming"
Now run these registry repair commands:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /t REG_EXPAND_SZ /d "%USERPROFILE%\Documents" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v AppData /t REG_EXPAND_SZ /d "%USERPROFILE%\AppData\Roaming" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%USERPROFILE%\AppData\Local" /f
Then run these:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Personal /t REG_SZ /d "%USERPROFILE%\Documents" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v AppData /t REG_SZ /d "%USERPROFILE%\AppData\Roaming" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Local AppData" /t REG_SZ /d "%USERPROFILE%\AppData\Local" /f

Step 3: Restart Windows​

  1. Restart the computer.
  2. After logging back in, open Command Prompt.
  3. Test PowerShell again:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NoExit

Step 4: Also test 32-bit PowerShell​

If the above still fails, try:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NoExit
Tell me whether both fail with the same message.

Step 5: If still failing, test whether it is your profile or Windows itself​

Create a temporary local admin account:
net user TestAdmin TempPass123! /add
net localgroup administrators TestAdmin /add
Then:
  1. Sign out.
  2. Sign in as TestAdmin.
  3. Try opening PowerShell.
If PowerShell works in TestAdmin, your original user profile is damaged. If it fails there too, the Windows PowerShell/.NET system components are damaged.
To remove the test account later:
net user TestAdmin /delete

Step 6: If it fails in every account​

Run these from Command Prompt as Administrator:
sfc /scannow
Then:
DISM /Online /Cleanup-Image /RestoreHealth
Then restart and test again.
The key clue is that your Desktop shell folder value was already missing. So before assuming PowerShell itself is broken, I’d repair the related Documents/AppData/Local AppData paths first.
 
Excellent, davercrb2 — that confirms the problem was almost certainly caused by missing/corrupted user shell folder paths, not PowerShell itself.

Do these quick final checks​

  1. In the open PowerShell window, run:
$HOME
  1. Then run:
  1. Then run:
  1. Then run:
You should see paths similar to:
Code:
C:\Users\daver
C:\Users\daver\Documents
C:\Users\daver\AppData\Roaming
C:\Users\daver\AppData\Local

One more recommended repair​

Since more than one shell folder value was damaged, I still recommend running a system file check when convenient.
  1. Open Command Prompt as Administrator.
  2. Run:
sfc /scannow
  1. If SFC reports it repaired files, restart the PC.

Optional cleanup​

If you created the registry backup files on the Desktop, keep them for a few days:
Code:
UserShellFolders-backup.reg
ShellFolders-backup.reg
Once everything remains stable after a restart or two, you can delete those backup .reg files.
Glad we got PowerShell opening again.
 
Done. Looks like everything is stable.
 

Great, davercrb2 — glad to hear everything is stable now.
It looks like the root cause was corrupted or missing user shell folder registry entries, which affected both:
Desktop location and PowerShell startup
A few final recommendations:
  1. Keep the .reg backup files for a few days if they were created.
  2. Restart once more later and confirm the Desktop and PowerShell still behave normally.
  3. Run this when convenient from Command Prompt as Administrator:
sfc /scannow
  1. Avoid deleting any of the system folders that previously appeared on the Desktop.
  2. If this returns, consider creating a new Windows restore point after confirming the system is healthy.
Glad we got both issues resolved.
 
Sounds good, davercrb2 — glad the restart went well and everything is stable.
If the issue comes back, the first things to recheck would be:
  1. The Desktop path under user shell folders.
  2. The Documents/AppData/Local AppData shell folder entries.
  3. sfc /scannow from an elevated Command Prompt.
For now, you should be all set.
 
Back
Top