PSConnectWise icon indicating copy to clipboard operation
PSConnectWise copied to clipboard

ConnectWise time normalization

Open mrmarkwest opened this issue 9 years ago • 5 comments

In trying to do a Create-CWConfig function, I ran into this terrible annoyance with the way that CW needs to receive [datetime] via the API. I wrote this little function that helps. Figured it would help you and your users so they didn't bang their head against the same problems I did.

function ConvertTo-CWTime { Param ( [Parameter(Mandatory = $True,Position = 0)] [datetime]$dateTime ) $MyTZone = Get-TimeZone $datetime = "{0:yyyy-MM-ddThh:mm:ssZ}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($dateTime, $MyTZone) return $datetime }

mrmarkwest avatar Jan 31 '17 00:01 mrmarkwest

This may have been repaired as I just used:

Add-CWTimeEntry -TicketID 140830 -MemberID 150 -Start "April 6, 2017 8:00:00 AM" -End "April 6 2017 5:00:00 PM" -Message @"MULTILINE STRING"@ -AddToDescription

with no issue. Either there is a specific issue with Create-CWConfig (which I don't see in the repository), your PC's Region/Language settings, or it's gone away.

Regardless thanks for the tip. Added this to my scripts folder. :)

BrianBtheITguy avatar Apr 10 '17 05:04 BrianBtheITguy

Thanks sir, trying to figure out how to contribute... As I'd really like to add on what I've done and not re-do what you have already done.

mrmarkwest avatar May 12 '17 00:05 mrmarkwest

So, I've come across this issue again, when I am attempting to create an Agreement.

  "code": "UnsupportedFormat",
  "message": "Unsupported format applied to startDate",
  "resource": "agreement",
  "field": "startDate"

I wonder if it is that I am only needing to pass a date in my example, and you have to define time as well. hmm..

mrmarkwest avatar May 25 '17 21:05 mrmarkwest

@mrmarkwest I welcome contributions. You will need to fork master, commit the changes to your fork, then submit pull requests.

sgtoj avatar May 25 '17 22:05 sgtoj

If you check out page #41 you will see that some other issues like this. I think it has to do with Zulu time being used instead of local time.

BrianBtheITguy avatar Jun 15 '17 21:06 BrianBtheITguy