Description
This Article describes how to build a query that will return device that have been Updated by Inventory within X. Where X can be specified within hours. In this example I will show examples for the last 24, 12 and 6 hours.
GetDate():
The Get-Date cmdlet gets a DateTime object that represents the current date or a date that you specify. It can format the date and time in several Windows and UNIX formats. You can use Get-Date to generate a date or time character string, and then send the string to other cmdlets or programs.
Query Builder:
Depending on your use case you can either choose a Greater Than ">" statement to show results within the desired length of time or "<" Less Than" for results outside of the desired time frame.
Build Your Query:
- In the Windows console right click on My Queries and click New Query.
- In the Machine Components section scroll near the bottom and select the attribute labeled: Last Updated by Inventory Server
- In the Relational Operators section select the Greater Than symbol >
- In the Display Scanned Values section, we will determine our time range by using the variable GetDate() with a switch that turns the variable a time in the past. For Example GetDate()-1would indicate today's date and time minus one day.
Last 30 days
- GetDate()-30
Last 36 Hours
- GetDate()-1.5
Last 24 hours
- GetDate()-1
Last 12 hours
- GetDate()-0.5
Note the use of a decimal to depict the time in hours. If GetDate()-1indicates one day or 24 hours then GetDate()-0.5would indicate 12 hours or GetDate()-1.5 would indicate 36 hours and so on...