I'm facing an issue while trying to set an alias using PowerShell (oh-my-posh) on Windows 11. I have successfully created aliases before, like opening Notepad++ using
Set-Alias np path_to_notepad_exe.
However, I'm having trouble creating a new alias to run netsh wlan show profile
using
Set-Alias wsp 'netsh wlan show profile'
.
After updating the user_profile.ps1 file located at
C:\Users\CurrentUserAccount.config\powershell\user_profile.ps1
, I encounter the following error when running the command wsp :
wsp
The term 'netsh wlan show profile' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
also , I've tried multiple approaches to resolve this issue:
$PROFILE
and added this line of code to it:New-Alias -Name wlan -Value "netsh wlan show profile"
function Show-WlanProfiles {
netsh wlan show profile
}
I've ensured that the path is correct and tried different variations of the alias definition, but I can't seem to get it to work. What am I missing here? How can I properly set an alias for this command?
Any assistance would be greatly appreciated. Thank you! alias in user_profile.pa1 the error
Try the following code :
Function Show-WlanProfiles {netsh wlan show profile}
Set-Alias -Name wlan -Value Show-WlanProfiles
Read more from official documentation