0

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:

  1. I updated my $PROFILE and added this line of code to it:
New-Alias -Name wlan -Value "netsh wlan show profile"

  1. I also attempted using a function definition like this:
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

  • You can’t apply parameters in an alias - the best you can do is wrap the command in a function and create an alias for that. This is a multiple duplicate question - I’ll see if I can find a link to a previous one… – mclayton Aug 26 '23 at 19:44
  • Here’s one - https://stackoverflow.com/questions/69072117/make-alias-in-powershell-to-run-the-command-that-may-include-further-parameters - but I’m pretty sure I’ve seen this same question multiple times over the years… – mclayton Aug 26 '23 at 19:45
  • Also https://stackoverflow.com/a/70828654/3156906 and https://stackoverflow.com/questions/63968913/powershell-md5sum-alias – mclayton Aug 26 '23 at 19:50

0 Answers0