cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Patrickc
Engaged Sweeper
I have a modified computer inventory query that I would like to run, but i'm having troubles tracking down the exact problem.

Basically I would like to be able to grab the last username that logged into a computer and grab the AD OU that particular user is located in.

When I attempt to run this I get the "Conversion failed when converting the nvarchar value 'ou=orange,ou=users,dc=*****,dc=com' to data type int"

Here is my code with the red parts the portion that I added that broke the report.

Select Top 1000000 dbo.tblComputers.Computername,
dbo.tblComputers.ComputerUnique, Web40OSName.OSname,
dbo.web40ProcessorCapacity.[total Proc Capacity] As Clockspeed,
web40CorrectMemory.Memory, dbo.tblComputersystem.Manufacturer,
dbo.tblComputersystem.Model, dbo.tblComputers.Lastseen, Web40OSName.Compimage
As icon, dbo.web40ProcessorCapacity.CPU, dbo.tblComputers.Username,
dbo.tblComputers.LastknownIP, dbo.tblADusers.OU
From dbo.tblComputers Inner Join
dbo.web40ProcessorCapacity On dbo.tblComputers.Computername =
dbo.web40ProcessorCapacity.Computername Inner Join
dbo.tblComputersystem On dbo.tblComputers.Computername =
dbo.tblComputersystem.Computername Inner Join
dbo.tblADusers On dbo.tblComputers.Computername = dbo.tblADusers.OU Inner Join
dbo.tblOperatingsystem On dbo.tblComputers.Computername =
dbo.tblOperatingsystem.Computername Inner Join
dbo.web40ActiveComputers On dbo.tblComputers.Computername =
dbo.web40ActiveComputers.Computername Inner Join
web40CorrectMemory On web40CorrectMemory.Computername =
dbo.tblComputers.Computername Inner Join
Web40OSName On Web40OSName.Computername = dbo.tblComputers.Computername
Where (dbo.web40ProcessorCapacity.[total Proc Capacity] < 2000) Or
(web40CorrectMemory.Memory < 2048)
Order By dbo.tblComputers.Computer
1 REPLY 1
Hemoco
Lansweeper Alumni
A basic report to return the computer name, last logged in user and user OU looks like this:

Select Top 1000000 tblComputers.Computername, tblComputers.ComputerUnique,
tblComputers.Computer, tblCPlogoninfo.Domain, tblCPlogoninfo.Username As
[Last Logged On], Max(tblCPlogoninfo.logontime) As [Last Logon Date],
tblADusers.OU
From tblComputers Left Join
tblCPlogoninfo On tblCPlogoninfo.Computername = tblComputers.Computername
Left Join
tblADusers On tblADusers.Username = tblCPlogoninfo.Username And
tblCPlogoninfo.Domain = tblADusers.Userdomain
Group By tblComputers.Computername, tblComputers.ComputerUnique,
tblComputers.Computer, tblCPlogoninfo.Domain, tblCPlogoninfo.Username,
tblADusers.OU
Order By tblComputers.Computer