windows - Sorting in Powershell except few output -


i have multiple services. suppose starts . when execute

get-service a* - display services output starting a.

i sorting complete output except 1 , want on top of list once sorted. using below command.

get-service -displayname a* |sort-object {$_.name -ne 'ak'} 

it listing output in sorted way , ak on top below .

ak ar 

and on . keeping ak on top , sorting others. want same thing 2 services. ak , ar(suppose)- both should in ak , ar order @ top other services need sort. how add in existing code ar.

try -notin operator, can specify array of excludes:

get-service a* | sort-object {$_.name -notin "ak","ar"} 

this way ak , ar service on top of sorted list

edit: v2 simple , easy:

get-service a* | sort-object {"ak","ar" -notcontains $_.name} 

Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -