Below is the SQL code needed to retrieve all of the collections from ConfigMgr. This is useful when creating custom reports that need to be scoped to a specific collection. The query below selects the CollectionName and CollectionID columns and sorts the CollectionName column alphabetically.
If you need to make a copy of a group policy, using the Group Policy Management Console can be a slow process. Using PowerShell is a much faster process.
All you need is the name of the source GPO copied to the clipboard.
The last hardware scan is stored in the view v_GS_WORKSTATION_STATUS. When joined with either v_R_System_Valid or v_R_System, you can retrieve the last hardware scan for a computer.
The SQL code below will return the last hardware scan date for all computers in the ConfigMgr system.
v_R_System_Valid ON v_GS_WORKSTATION_STATUS.ResourceID=v_R_System_Valid.ResourceID
If you need to return the last hardware scan for a single computer you can use the query below to filter by the computer name. In this example, we filtered on computer ‘pc01’.