Here is the structure of my dupelog.csv:
COMPUTERNAME,USERNAME,PRINTERNAME
RUN5V3N502B,kvanmeeteren,RUNM7V-RAMS1
RUN5V3N502B,kvanmeeteren,RUNM7V-RAMS1
RUN5V3N502B,kvanmeeteren,RUNM7V-RAMS1
and the relevant portion of my script (there is a lot of variable output just to doublecheck it is correct)
$dupeLog = "\\server\temp\PrintServerMigration\failures.csv"
$files = Get-ChildItem -Path \\server\temp\PrintServerMigration\*.csv | Where-Object { $_.LastWriteTime -ge (Get-Date).Date -and $_.Name -notlike "failures.csv" } | Select-Object -ExpandProperty fullname
foreach ($file in $files)
{
Write-Host "Processing file $file"
$data = Import-Csv -Path $file | Where-Object { $_.returncode_errormessage -eq '3019' } | Get-Unique
if ($data -ne $null)
{
$computerName = $data.computername
$computerName
pause
$userName = $data.username
$userName
pause
$printerName = $data.printername
$printerName
pause
$printerName = $printerName.TrimStart("\\printserver\")
$printerName
pause
Write-Host "Found 3019 Error on $computerName - checking log to prevent duplicate notifications"
$dupeCheck = Import-Csv -Path $dupeLog | Where-Object { $_.computername -eq "$computerName" -and $_.username -eq "$userName" -and $_.printername -eq "$printerName" }
$dupeCheck
pause
#$printerDriver = Invoke-Command printserver -ScriptBlock { Get-printer $using:printerName | Select-Object -ExpandProperty DriverName }
if ($dupeCheck -eq $null)
{
$printerDriver = Invoke-Command printserver -ScriptBlock { Get-printer $using:printerName | Select-Object -ExpandProperty DriverName }
#Send-MailMessage -SmtpServer mailserver -From printmigration@donotreply.com -To recipient@gmail.com -Subject "Failed driver install for $printerName for $userName on $computerName ($printerDriver)"
Write-Host "No previous errors logged for this. Emailing HelpSTAR and adding to the log so no duplicate emails get sent"
}
This is the particular line that isn’t returning anything. I’ve tried all sorts of different things in the where-object, but nothing ever gets returned.
$dupeCheck = Import-Csv -Path $dupeLog | Where-Object { $.computername -eq “$computerName” -and $.username -eq “$userName” -and $_.printername -eq “$printerName” }