I am having trouble with windows 11 %USERPROFILE% variable not working in admin powershell.
I was google searching windows 11 Save all wifi passwords to a text file. One of the ai answers were.
It complained:
So then I wanted to make sure %USERPROFILE% was set and for some reason it is not set in the admin powershell.
When I do windows run %USERPROFILE% it opens the %USERPROFILE% folder so why in the admin powershell will it not work?
I also found this
www.tenforums.com
This command ran fine.
Why does userprofile seem to work but %USERPROFILE% does not work in the admin powershell?
I found a superuser post that said not to use %USERPROFILE% with no explanation.
superuser.com
mkdir C:\Users\%USERPROFILE%\AppData\Roaming\modinstaller\recovery<br>
use this:
mkdir $home\AppData\Roaming\modinstaller\recovery<br>
I was google searching windows 11 Save all wifi passwords to a text file. One of the ai answers were.
Code:
netsh wlan show profiles | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); netsh wlan show profile name="$name" key=clear | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); "$name : $pass"}} > %userprofile%\Desktop\wifi_passwords.txt
It complained:
Code:
PS C:\Users\ghost> netsh wlan show profiles | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); netsh wlan show profile name="$name" key=clear | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); "$name : $pass"}} > %userprofile%\Desktop\wifi_passwords.txt
out-file : Could not find a part of the path 'C:\Users\ghost\%userprofile%\Desktop\wifi_passwords.txt'.
At line:1 char:1
+ netsh wlan show profiles | Select-String "\:(.+)$" | %{$name=$_.Match ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], DirectoryNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
So then I wanted to make sure %USERPROFILE% was set and for some reason it is not set in the admin powershell.
Code:
PS C:\Users\ghost> echo %USERPROFILE%
%USERPROFILE%
PS C:\Users\ghost>
When I do windows run %USERPROFILE% it opens the %USERPROFILE% folder so why in the admin powershell will it not work?
I also found this
See Wireless Network Security Key Password in Windows 10
How to See Your Wireless Network Security Key Password in Windows 10
This command ran fine.
Code:
(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -Wrap | Out-File "$env:userprofile\Desktop\WirelessNetworkPasswords.txt"
Why does userprofile seem to work but %USERPROFILE% does not work in the admin powershell?
I found a superuser post that said not to use %USERPROFILE% with no explanation.
%USERPROFILE% variable not working
If I try to create files in the command prompt using the commands mkdir C:\Users\Tristan\AppData\Roaming\modinstaller\recovery mkdir C:\Users\Tristan\AppData\Roaming\modinstaller\mods my computer ...
mkdir C:\Users\%USERPROFILE%\AppData\Roaming\modinstaller\recovery<br>
use this:
mkdir $home\AppData\Roaming\modinstaller\recovery<br>
My Computer
System One
-
- OS
- 10 and 11
- Computer type
- Laptop








