Need powershell script

Need a powershell code to remove the list of servers in first file based on the second file details. The second file contains the list of the server details that needs to be removed in the first file. Both the files will be in CSV format. As I am new to scripting please edit the script and provide the same.
Error “Method invocation failed because [System.Management.Automation.PSCustomObject] doesn’t contain a method named ‘IndexOf’”.
As Iam new to scripting please reframe the script and provide it.

$serverlist_csv1 = Import-Csv -Path $file1
$serverlist_temp1 = $serverlist_csv1
$exclude_serverlist_csv = Import-Csv -Path $file2
foreach ($server in $exclude_serverlist_csv) {
$servers1 = ($serverlist_csv1.‘SourceHostName’ | Select-Object -ExcludeProperty ‘SourceHostName’)

if ($servers1 -contains $server.'Exclude Server') {
    $server_object1 = ($serverlist_csv1 | Where-Object {$_.SourceHostName -eq $server.'Exclude Server'})

    $serverindex1 = $serverlist_csv1.IndexOf($server_object1) 
    $dataResizable1 = {$serverlist_csv1}.Invoke()
    $serverlist_csv1 = $dataResizable1


which columns and headers do you have in your csv files?

also, please try to run each line in a time, to figureout when the problem is occurred.

this is the first step for troubleshoot…