sgtoj / PSConnectWise

PowerShell Module that provide several CmdLets to interact with ConnectWise REST API service.
MIT License
45 stars 13 forks source link

Deprecated? #41

Open dmcearchern opened 7 years ago

dmcearchern commented 7 years ago

I used to run a query to array ticket ids based on a filter (see below). These appears to no longer be working?

$aSR1 = @(Get-CWServiceTicket -Filter "status/name='Acknowledged' and board/id=20 and company/id!=2 and summary not like '%No AV Found' and summary not like '%Standard Services - {Severity1}%' and summary not like '%Critical Event 41' and closedDate>=[ $sYesterday T23:59:59Z]" -Server $oCWServer | select ID)

BrianBtheITguy commented 7 years ago

First of all, the "-Server" command never worked for me. Maybe because I was already authenticated...

Assuming that's not your problem, the issue is specifically with "closedDate" being NULL and generates this error:

Cannot index into a null array. At D:\PSRoot\GIT\PSConnectWise\PSConnectWise\Private\PSCWApiClasses.ps1:640 char:9 $response = $this.ReadRequest($relativePathUri, $queryParams) ...


    CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    FullyQualifiedErrorId : NullArray

I could not get a workaround for this inside the -Filter block as it seems that the block is not processed "in order". However, I was able to come up with this code which I think will suit your needs:

$aSR1 = @(Get-CWServiceTicket -Filter "status/name='Acknowledged' and board/id=20 and company/id!=2 and summary not like '%No AV Found' and summary not like '%Standard Services - {Severity1}%' and summary not like '%Critical Event 41' and closedFlag=TRUE" | where ($_.closedDate -ge [$sYesterday T23:59:59Z]) | Select ID)

One thing I'm wondering is why you are trying to check the closedDate of tickets in acknowledged status. One would assume you have a status such as "Resolved" or "Completed". But I digress...In order to fix this to test on my network (I left most of the stuff there) I had to change the board/id, which of course makes sense. However, I also had to change

status/name='Acknowledged'

to

status/name='Completed'

on my end. I did not test the [$sYesterday T23:59:59Z] part so it might not work. However, for me, it worked with just using $sYesterday. Presumably you'd have to do some extra work to make it say DD:MM:YYYY-00:00:00 which I'm assuming you want to do.

sgtoj commented 7 years ago

This project isn't deprecated. However, there hasn't been any progress because I have been focused on other work and non-work projects. In between those projects, I have been thinking about the future of this project. See #43 for more information.