Ah, glorious! I'm sure I can cannibalize that to my requirements ;-)

Thankyou

From: [email protected] [mailto:[email protected]] On 
Behalf Of Webster
Sent: 21 October 2015 14:36
To: [email protected]
Subject: [NTSysADM] Re: PowerShell brain block


>From the end of all my documentation scripts:



#http://poshtips.com/measuring-elapsed-time-in-powershell/
Write-Verbose "$(Get-Date): Script started: $($Script:StartTime)"
Write-Verbose "$(Get-Date): Script ended: $(Get-Date)"
$runtime = $(Get-Date) - $Script:StartTime
$Str = [string]::format("{0} days, {1} hours, {2} minutes, {3}.{4} seconds", `
 $runtime.Days, `
 $runtime.Hours, `
 $runtime.Minutes, `
 $runtime.Seconds,
 $runtime.Milliseconds)
Write-Verbose "$(Get-Date): Elapsed time: $($Str)"



Carl Webster

Consultant and Citrix Technology Professional

http://www.CarlWebster.com<http://www.carlwebster.com/>

________________________________
From: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>> on 
behalf of James Rankin <[email protected]<mailto:[email protected]>>
Sent: Wednesday, October 21, 2015 7:34 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] PowerShell brain block


I'm having a bad day, struggling with basic PowerShell functionality, help :(



I'm trying to use the following command to return the difference between two 
times



New-TimeSpan -Start $StartDate -End $EndDate



Which works fine, but it returns a bunch of stuff like



Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 25

Milliseconds      : 464

Ticks             : 254647496

TotalDays         : 0.000294730898148148

TotalHours        : 0.00707354155555556

TotalMinutes      : 0.424412493333333

TotalSeconds      : 25.4647496

TotalMilliseconds : 25464.7496



I just want to get it to return something like



0 Hours, 0 Minutes, 25 seconds



...but I'm having a total mental block and I appear to have lost the ability to 
do simple manipulation of PowerShell output, all I am managing after quite some 
time is a single line from



(New-TimeSpan -Start $StartDate -End $EndDate).TotalSeconds



Which just gives me "25"



can someone put me out of my misery?



Cheers,







James Rankin

EUC Director | HTG TaloSys | 07809 668579 | 
[email protected]<mailto:[email protected]>

One Trinity Green, Eldon Street, South Shields, Tyne & Wear, NE33 1SA

Tel: 0191 481 3489

Email address: [email protected]<mailto:[email protected]>

Website: www.talosys.co.uk<http://www.talosys.co.uk>

[phpy9YoGNAM]



Reply via email to