Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2014 02:25 PM
Hi,
I'm writing a Powershell script to update descriptions in AD for each machine.
Essentially I'm including details in the following format:
User Display Name [19/09/14 08:37:23] [HP ProBook 450 G2] [Windows 7 Professional (x64) SP1]
I took the query below from another post on this forum, but it seems to look at an individual's last logon location, so if a user logs on to multiple machines and I make a change to the format above, it will only be picked up for the machine that the user has most recently logged on to.
Essentially, I'd like for this report to output all of the same info. but instead focus the query on the last user for each asset, instead of it being the other way around!
Is anybody able to help? 🙂
Cheers,
Matt
I'm writing a Powershell script to update descriptions in AD for each machine.
Essentially I'm including details in the following format:
User Display Name [19/09/14 08:37:23] [HP ProBook 450 G2] [Windows 7 Professional (x64) SP1]
I took the query below from another post on this forum, but it seems to look at an individual's last logon location, so if a user logs on to multiple machines and I make a change to the format above, it will only be picked up for the machine that the user has most recently logged on to.
Select Top 1000000 SubQuery.Username,
SubQuery.Domain As Userdomain,
SubQuery.LastLogon,
tblAssets.AssetName as ComputerName,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssets.Domain,
tblOperatingsystem.Caption as OperatingSystem,
tblComputersystem.SystemType,
tblOperatingsystem.ServicePackMajorVersion as ServicePack
From tblCPlogoninfo
Inner Join (Select Top 1000000 tblCPlogoninfo.Username,
tblCPlogoninfo.Domain,
Max(tblCPlogoninfo.logontime) As LastLogon
From tblCPlogoninfo
Group By tblCPlogoninfo.Username,
tblCPlogoninfo.Domain) SubQuery On tblCPlogoninfo.Username =
SubQuery.Username And tblCPlogoninfo.Domain = SubQuery.Domain And
tblCPlogoninfo.logontime = SubQuery.LastLogon
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblOperatingSystem On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblComputersystem on tblAssets.AssetID = tblComputersystem.AssetID
Essentially, I'd like for this report to output all of the same info. but instead focus the query on the last user for each asset, instead of it being the other way around!
Is anybody able to help? 🙂
Cheers,
Matt
Solved! Go to Solution.
Labels:
- Labels:
-
Report Center
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2014 06:49 PM
Please use the following report:
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain As [last user domain],
tblAssets.Username As [last user],
Max(tblCPlogoninfo.logontime) As 'last logon'
From tblCPlogoninfo
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain,
tblAssets.Username
To use the report above, do the following:
•Open the report builder under Reports/Create New Report.
•Paste the SQL code we provided at the bottom of the page.
•Left-click somewhere in the upper section of the page so the code applies.
•Give the report a Title and hit the Save & Run button to save it. Export options are listed on the left.
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain As [last user domain],
tblAssets.Username As [last user],
Max(tblCPlogoninfo.logontime) As 'last logon'
From tblCPlogoninfo
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain,
tblAssets.Username
To use the report above, do the following:
•Open the report builder under Reports/Create New Report.
•Paste the SQL code we provided at the bottom of the page.
•Left-click somewhere in the upper section of the page so the code applies.
•Give the report a Title and hit the Save & Run button to save it. Export options are listed on the left.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2014 03:51 AM
'last logon' should be [last logon].
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2014 07:50 PM
Exactly what I needed!
Thank
Thank
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2014 06:49 PM
Please use the following report:
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain As [last user domain],
tblAssets.Username As [last user],
Max(tblCPlogoninfo.logontime) As 'last logon'
From tblCPlogoninfo
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain,
tblAssets.Username
To use the report above, do the following:
•Open the report builder under Reports/Create New Report.
•Paste the SQL code we provided at the bottom of the page.
•Left-click somewhere in the upper section of the page so the code applies.
•Give the report a Title and hit the Save & Run button to save it. Export options are listed on the left.
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain As [last user domain],
tblAssets.Username As [last user],
Max(tblCPlogoninfo.logontime) As 'last logon'
From tblCPlogoninfo
Inner Join tblAssets On tblAssets.AssetID = tblCPlogoninfo.AssetID
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Userdomain,
tblAssets.Username
To use the report above, do the following:
•Open the report builder under Reports/Create New Report.
•Paste the SQL code we provided at the bottom of the page.
•Left-click somewhere in the upper section of the page so the code applies.
•Give the report a Title and hit the Save & Run button to save it. Export options are listed on the left.