PowerShell script exchange
dalfa
Novice
Posts: 6 Liked: never
Joined: May 11, 2016 8:59 am
Full Name: Fabrizio
Contact:
Post
by dalfa » Feb 01, 2017 3:53 pm
this post
Hello,
I'm trying to get job time in utc, in order to compare events between veeam b&r and guest machines but all the so-called xxxxxUTC entities seem to always report the localized datetime, eg.
Code: Select all
PS C:\Users\changemanager> (get-date).ToUniversalTime()
Wednesday, February 01, 2017 3:47:34 PM
PS C:\Users\changemanager> get-date
Wednesday, February 01, 2017 11:47:37 AM
PS C:\Users\changemanager> Get-VBRBackupSession|select -last 1 |select CreationTime, CreationTimeUTC
CreationTime CreationTimeUTC
------------ ---------------
1/17/2017 3:45:13 AM 1/17/2017 3:45:13 AM
Where am I going wrong?
thanks and regards,
Fabrizio
veremin
Product Manager
Posts: 20415 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Feb 02, 2017 1:58 pm
this post
Chances are, there is some bug affecting in time reflection logic. The fix is simple, though, just leverage ToUniversalTime() method:
Code: Select all
$Session = Get-VBRBackupSession | sort creationtime -Descending | select -first 1
$Session.CreationTime.ToUniversalTime()
Thanks.
dalfa
Novice
Posts: 6 Liked: never
Joined: May 11, 2016 8:59 am
Full Name: Fabrizio
Contact:
Post
by dalfa » Feb 03, 2017 2:01 pm
this post
Hi Vladimir,
Great, it works! I tried
Code: Select all
(Get-VBRBackupSession | select -last 1 | select-object CreationTime) .ToUniversalTime ()
but I was not fully aware of select-object behaviour.. so, I have to explicitly use variables instead of piping to select-object.
thanks and regards,
Fabrizio
veremin
Product Manager
Posts: 20415 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Feb 03, 2017 2:07 pm
this post
Yep, you can use select cmdlet this way. If you want to get the latest session of particular job, you can add a job name as filter option:
Code: Select all
$Session = Get-VBRBackupSession | where {$_.name -like "*Name of your backup job*"}| sort creationtime -Descending | select -first 1
$Session | select name, {$_.creationtime.touniversalTime()}
Thanks.
dalfa
Novice
Posts: 6 Liked: never
Joined: May 11, 2016 8:59 am
Full Name: Fabrizio
Contact:
Post
by dalfa » Feb 07, 2017 4:40 pm
this post
Great! Today, too, I Learned Something New
best regards,
Fabrizio
veremin
Product Manager
Posts: 20415 Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Feb 08, 2017 7:12 pm
this post
Trust me - there is a lot to learn in PowerShell. No once will it be able to surprise you.
Glad to hear that my input has been helpful for you.
Users browsing this forum: No registered users and 14 guests