I have a 2 CSV and I want to import 3 columns (FoundInAD,Results,Uptime) from CSV2 to CSV1 and I do not know how to do it, hoping that someone could help on this.
CSV1
ComputerName
PatchingStyle
LastSyncTime
LastSyncResult
LastReportedStatusTime
PendingReboot
NeededCount
Compliant
Server1
7Saturday9PM
4/15/2020 18:31
Succeeded
4/15/2020 19:24
0
0
100
CSV2
ServerName
Uptime
Results
FoundInAD
Server1
241 Days; 14 Hrs; 6 Mins; 47 Secs
Up
YES
I tried this code but it is not working, am getting .
When you post code or error messages or sample data or console output format it as code using the code tags “PRE”, please. Thanks in advance.
I assume you want to combine both CSVs based on the columns $CSV1.ComputerName and $CSV2.ServerName, right? You cannot use a nested loop for that. You have to match the current element of one of the arrays to the according one of the other array … like this maybe:
I could not recognize that in your sample data. So you have to convert the FQDN to a hostname to make it comparable to the hostname from your CSV2. Do you need help with that?
yes, if there is other way without changing the servername to FQDN… I use the hostname to find the device in AD, if I change that to FQDN the value from FoundInAD will be the issue.