Я думаю, вы можете сократить это повторение -cnotlike
, используя регулярное выражение -cnotmath
, например:
$re = "AppUp\.IntelGraphicsControlPanel|NVIDIACorp\.NVIDIAControlPanel|.*Store.*"
Get-AppxProvisionedPackage -Online |
Where-Object {$_.DisplayName -cnotmatch $re} |
Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
Regex Подробности:
Match this alternative (attempting the next alternative only if this one fails)
AppUp Match the character string “AppUp” literally (case sensitive)
\. Match the character “.” literally
IntelGraphicsControlPanel Match the character string “IntelGraphicsControlPanel” literally (case sensitive)
|
Or match this alternative (attempting the next alternative only if this one fails)
NVIDIACorp Match the character string “NVIDIACorp” literally (case sensitive)
\. Match the character “.” literally
NVIDIAControlPanel Match the character string “NVIDIAControlPanel” literally (case sensitive)
|
Or match this alternative (the entire match attempt fails if this one fails to match)
. Match any single character that is NOT a line break character (line feed)
* Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Store Match the character string “Store” literally (case sensitive)
. Match any single character that is NOT a line break character (line feed)
* Between zero and unlimited times, as many times as possible, giving back as needed (greedy)