Author Posts

March 29, 2018 at 7:28 am

Hi Guys,
Any help would be appreciated as I have no idea how to tackle this.
I am pulling storage space information from PRTG using a web API request.
I end up with an array with the below data.
1/01/2018 7:00:00 PM – 8:00:00 PM 5497289703424.00
1/01/2018 8:00:00 PM – 9:00:00 PM 5497289703424.00
1/01/2018 9:00:00 PM – 10:00:00 PM 5497289703424.00
1/01/2018 10:00:00 PM – 11:00:00 PM 5497289703424.00
1/01/2018 11:00:00 PM – 12:00:00 AM 5497289703424.00
2/01/2018 12:00:00 AM – 1:00:00 AM 5497289703424.00
2/01/2018 1:00:00 AM – 2:00:00 AM 5497289703424.00
2/01/2018 2:00:00 AM – 3:00:00 AM 5497289703424.00
2/01/2018 3:00:00 AM – 4:00:00 AM 5497289703424.00
2/01/2018 4:00:00 AM – 5:00:00 AM 5497289703424.00
2/01/2018 5:00:00 AM – 6:00:00 AM 5497289703424.00

I only want to keep the first line on each day. How could i remove the rest and accomplish this?

Thanks
Douglas

March 29, 2018 at 7:42 am

you could do something like this

$myarray = @(
("1/01/2018 7:00:00 PM – 8:00:00 PM 5497289703424.00"),
("1/01/2018 8:00:00 PM – 9:00:00 PM 5497289703424.00"),
("1/01/2018 9:00:00 PM – 10:00:00 PM 5497289703424.00"),
("1/01/2018 10:00:00 PM – 11:00:00 PM 5497289703424.00"),
("1/01/2018 11:00:00 PM – 12:00:00 AM 5497289703424.00"),
("2/01/2018 12:00:00 AM – 1:00:00 AM 5497289703424.00"),
("2/01/2018 1:00:00 AM – 2:00:00 AM 5497289703424.00"),
("2/01/2018 2:00:00 AM – 3:00:00 AM 5497289703424.00"),
("2/01/2018 3:00:00 AM – 4:00:00 AM 5497289703424.00"),
("2/01/2018 4:00:00 AM – 5:00:00 AM 5497289703424.00"),
("2/01/2018 5:00:00 AM – 6:00:00 AM 5497289703424.00")

)

$myarray | select -First 1

March 29, 2018 at 7:43 am

Thanks but i figured it. Funny how you leave it for a while and it comes to you when you are not thinking about it 🙂

I ended up doing
$array | select "Date Time", "Available Capacity(RAW)", "Free Bytes(RAW)" | Where-Object {$_."Date Time" -like "*12:00:00 AM – 1:00:00 AM*"}
This gave the one data point per day. So simple I don't know why i didn't see it earlier.

Thanks
Douglas

March 29, 2018 at 7:44 am

or you could just do
$myarray[0]