I'm trying to sort trough a recent report of PCs users don't seem to be using, for that ive got a CSV file called report, and a CVS file of all our PC's called data.
Report and Data only share 1 column which is the users full name, how can i get a result which provides both the users full name and the PC which is only from report?
So far i have the following code which works for getting the users full name, but I'm unsure how to get the device
$report = Import-Csv "C:\Temp\\report.CSV" -Delimiter ";"
$data = Import-Csv "C:\Temp\\data.CSV" -Delimiter ";"
$UserOutput = @()
ForEach ($name in $report)
{
$userMatch = $data | where {$_.FullName -like $name.FullName}
If($userMatch)
{
$UserOutput += New-Object PsObject -Property @{UserName =$name.FullName;Device=$userMatch.Device}
}
else
{
$UserOutput += New-Object PsObject -Property @{UserName =$name.FullName;Device ="NA"}
}
}
$UserOutput | ft
This gives a nice list, but i cant find the devices so it ends up looking like this
Device UserName
------ --------
NA Anders Aadal Jensen
NA Andr�s Kov�cs
NA Anette Dahnke