0

I have one excel file and a SharePoint list(Employee master). I want to extract the user in csv file who is not in the SharePoint list(Employee Master).

If the employee not exists in SharePoint list we treat him as user terminated for internal tracking.

Please provide the PowerShell solution or if any other way.

1 Answer 1

0

Here is a script which work in my end. I used title column in csv file just for testing. You can replace the placeholder with the column name in your list. I only test with single text column. If you are using people and group column for user name. It may needs a bit more work and just let me know.

$ListName="<ListName>"
$csv=Import-Csv "<CSV file Path>"
$webURL="<Site URL>"
$web=Get-SPWeb $webURl
$list=$web.Lists | Where-Object { $_.Title -Eq $ListName }
$TerminatedUserList=@()
foreach ($row in $csv) 
{ 
    $Items= $list.items | where {$_['<column Name>'] -eq $row.Title}
    If($Items.Length -eq 0)
    {
        write-host $row.Title "does not exist in the SP list"
        $TerminatedUserList+=$row.Title
    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.