Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run my script because Powershell read "-" as –

Tags:

powershell

This is what I'm trying to run

Get-AppxPackage -AllUsers | where-object {$_.name –notlike "store"} | Remove-AppxPackage 2>&1 | Out-Null

And this is the error message I keep getting

At C:\Users\JKaw\Desktop\AfterFormat\Win10Tweaks.ps1:262 char:51 + ... ct {$_.name –notlike "store"} | Remove-AppxPackage 2>&1 | Out-Nul ...

–notlike > –notlike

Is there any workaround for this? I looked for a bit but didn't find any solution!

like image 364
JKaw Avatar asked Feb 03 '26 07:02

JKaw


1 Answers

Don't copy commands off websites into a console. Retype them.

You have copied the command, including the dash character which a website turned into a fancy Unicode dash just because it could (I'm looking at you, Wordpress), into a non-Unicode-aware console.

This causes the UTF-8-encoded bytes that make up the character to be interpreted as ANSI (in whatever codepage).

like image 94
CodeCaster Avatar answered Feb 06 '26 02:02

CodeCaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!