I am trying to get a report that shows me all the workstations that do not have a specific reg key on them. On the report I am looking for the following fields:
tblAssets.AssetName,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblAssets.Username,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model
I want to see only the systems that
do not have the following reg key (key is present if built with MDT):
Key: HKEY_LOCAL_MACHINE\Software\Microsoft\Deployment 4
Value Name: Task Sequence Name
As a bonus, I would like to be able to filter out specific PC naming schemes based on the first 3 characters of the assetName such as "SGS%" or "SGV%". This would be a nice to have, not a must have.
I've tried various pieces of code. Either I get empty lists or lists that show systems that do have the key on them. Here is the last code I tried to use:
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblAssets.Username,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Where tblAssets.AssetID Not In (Select Top 1000000 tblAssets.AssetID
From tblAssets Inner Join tblRegistry On tblAssets.AssetID =
tblRegistry.AssetID
Where tblRegistry.Regkey Like '%SoftwareMicrosoftDeployment 4' And
tblRegistry.Valuename = 'Task Sequence Name') And tblAssets.Lastseen <> ''
And tsysAssetTypes.AssetTypename = 'windows' And tblAssetCustom.State = 1
Order By tblAssets.Domain,
tblAssets.AssetName
Any help is appreciated.