Advertisement
guyrleech

Show approximate clock differences

Aug 13th, 2021
1,799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Get a credential - only required if not in same domain and no trust or user doesn't have permission. Note -message for anti-phishing as that will appear in the credential prompt
  2. $cred = Get-Credential -Message wert3q245352er
  3.  
  4. ## Create a remote PS session so our clock difference measurement doesn't also measure session establishment. Don't necessarily need credentials
  5. $sesh = New-PSSession -Credential $cred -ComputerName glxa19pvs301.guyrleech.local
  6.  
  7. ## Get the difference between remote and local clocks 10 times and show average. There will be a small delay as run sequentially not in parallel
  8. 1..10 |ForEach-Object { (Invoke-Command -Session $sesh -ScriptBlock {Get-Date}) - (Get-Date) } | Measure-Object -Property TotalMilliseconds -Average | Select-Object -Property Average
  9.  
  10. ## Close the remote session
  11. Remove-PSSession -Session $sesh
  12. $sesh = $null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement