Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Username = 'username'
- $Password = 'password'
- $pass = ConvertTo-SecureString -AsPlainText $Password -Force
- $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
- $timeOnADFS = invoke-command -ComputerName ip.of.problem.server -ScriptBlock {get-date -UFormat %T} -Credential $Cred
- $timeOnLocal = get-date -UFormat %T
- echo "Time on ADFS server: $timeOnADFS"
- echo "time on exchange server: $timeOnLocal"
- $difference = (new-timespan -start $timeOnADFS -end $timeOnLocal).Minutes
- $difference
- if (($difference -gt 2) -or ($difference -lt -2)) {
- send-mailmessage -from "timeWarning@youremail.com" -to "thePeopleWhoWillFixIt@youremail.com" -subject "time difference is $difference" -body "time difference is $difference" -smtpserver "yourRelayServer.FQDN"
- }
Add Comment
Please, Sign In to add comment