Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
359 stars 170 forks source link

Number of records different when using the filter vs where. #258

Open mark3grahams opened 8 months ago

mark3grahams commented 8 months ago

Hi,

I am a bit new to this module, and I am wondering why I am getting different results.

Get-ServiceNowRecord -Table 'change request' -Filter @('opened_at', '-between', (Get-Date).AddMonths(-2), (Get-Date)), '-and', @('type', '-eq', 'Normal') -IncludeTotalCount WARNING: Getting 5 records...

number short_description state assigned_to approval cmdb_ci opened_at


CHG0070484 Add/Remove users from ... New John Smith Not Yet... 11-20-2023 02:19:1... CHG0070489 New John Smith Not Yet... 11-20-2023 02:51:3... CHG0070490 New John Smith Not Yet... 11-20-2023 02:55:4... CHG0070495 New John Smith Not Yet... 11-20-2023 03:28:1... CHG0070496 New John Smith Not Yet... 11-20-2023 03:28:3...

Get-ServiceNowRecord -Table 'change request' -Filter @('openedat', '-between', (Get-Date).AddMonths(-2), (Get-Date)) -IncludeTotalCount | Where-Object { $.type -eq 'Normal' } WARNING: Getting 36 records...

number short_description state assigned_to approval cmdb_ci opened_at


CHG0070484 Add/Remove users from ... New John Smith Not Yet... 11-20-2023 02:19:1... CHG0070489 New John Smith Not Yet... 11-20-2023 02:51:3... CHG0070490 New John Smith Not Yet... 11-20-2023 02:55:4... CHG0070491 Test New John Smith Requested 11-20-2023 03:23:5... CHG0070495 New John Smith Not Yet... 11-20-2023 03:28:1... CHG0070496 New John Smith Not Yet... 11-20-2023 03:28:3... CHG0070515 test New John Doe Approved 12-19-2023 12:01:5... CHG0070516 test New Jane Doe Requested 12-19-2023 01:54:5... CHG0070517 test New Jane Doe Requested 12-19-2023 02:00:0... CHG0070518 test New John Doe Approved 12-19-2023 02:02:0...

gdbarron commented 6 months ago

Have you confirmed type looks as expected?

Get-ServiceNowRecord -Table 'change request' -Filter @('opened_at', '-between', (Get-Date).AddMonths(-2), (Get-Date)) -IncludeTotalCount | Select -Property type