Jump to content


Established Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About cantgetanythingtowork

  • Rank
  1. Sorry if I caused confusion I'm trying to do a user query. The query above returns all users who have logged on to a workstation where the software metering rule matches. It also returns devices but that is of no consequence now since I only need the user for the final result. However, only one of those relationships is active and thus I want the where-clause to get a singular username who I can then remove from the application deployment collection and deploy application uninstall. The applications are deployed initially with requirement that the device it is installed on is users primary device. I am trying to achieve software-metering-uninstallation-automation for deployments that are user-targeted rather than device targeted.
  2. Hello. I'm having trouble making up a query for software metering. The query was adopted from some site and then modified to suit my purposes. I am however having problems adding a simple where-clause to this query. The query is as follows: Select SMS_R_System.ResourceID,SMS_R_System.Name,SMS_R_User.UniqueUserName FROM SMS_R_System JOIN SMS_UserMachineRelationship ON SMS_R_System.Name=SMS_UserMachineRelationship.MachineResourceName JOIN SMS_R_User ON SMS_UserMachineRelationship.UniqueUserName=SMS_R_User.UniqueUserName INNER JOIN SMS_G_System_SoftwareFile ON SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceID INNER JOIN SMS_MeteredFiles ON SMS_G_System_SoftwareFile.FileID = SMS_MeteredFiles.MeteredFileID INNER JOIN SMS_MeteredProductRule ON SMS_MeteredProductRule.RuleID = SMS_MeteredFiles.RuleID WHERE SMS_MeteredFiles.RuleID = 16777317 AND DateDiff(day, SMS_G_System_SoftwareFile.ModifiedDate, GetDate()) > 1 AND DateDiff(day, SMS_MeteredProductRule.LastUpdateTime, GetDate()) > 1 AND SMS_R_system.OperatingSystemNameAndVersion LIKE '%Workstation%' AND SMS_G_system_SoftwareFile.ResourceID NOT IN (SELECT DISTINCT SMS_MonthlyUsageSummary.ResourceID FROM SMS_MonthlyUsageSummary INNER JOIN SMS_MeteredFiles ON SMS_MonthlyUsageSummary.FileID = SMS_MeteredFile.MeteredFileID WHERE DateDiff(day, SMS_MonthlyUsageSummary.LastUsage, GetDate()) < 2 AND SMS_MeteredFiles.RuleID = 16777317) This works fine for the purpose, but I want to incorporate device affinity along with it. And to do that, I want to add 'WHERE SMS_UserMachineRelationship.RelationActive = '1'' somewhere but I don't know where. All my guesses have resulted in invalid query. This is for user collection. This was relatively easy to do for device deployments but I'm having hard time getting it to work for when a deployment is for user - and this is essential because the install deployment collection membership must first be deleted before the uninstall can be done.
  • Create New...