PowerShell script exchange
Post Reply
tleanna
Novice
Posts: 7
Liked: never
Joined: Jun 06, 2018 2:29 pm
Full Name: Troy Leanna
Contact:

Sort-Object

Post by tleanna »

I am working in a script that will be run via Task Scheduler, but testing it initially through the VBR PowerShell Toolkit...

I have this line of code that should pull in all jobs and sort the in Descending value

$Jobs = Get-VBRJob | Sort-Object -Descending

When I view the output, it does not sort them. Does anyone know why or how to sort them correctly?
Vitaliy S.
VP, Product Management
Posts: 27120
Liked: 2720 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Sort-Object

Post by Vitaliy S. »

Troy, how do you want to sort your jobs? Based on the time start, date, name or something else? There are some existing samples showing how you can query and sort objects using our PS snap-in, please take a look at them.
tleanna
Novice
Posts: 7
Liked: never
Joined: Jun 06, 2018 2:29 pm
Full Name: Troy Leanna
Contact:

Re: Sort-Object

Post by tleanna »

Sorry, I have been focused on my script that I did not see your reply... I was able to find some references on how to manipulate my script to perform this and have it working as I would like it to...
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Sort-Object

Post by veremin »

You need to specify a property that will be used as a sorting parameter. For instance, if you want to sort job based on their names, use the following script:

Code: Select all

Get-VBRJob | Sort-Object -Property Name
Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests