Actually I’m still not completely sure what exactly your issue is.
If you want to update one list with a property from another list you need to have a unique identifier in both lists. Usually the sAMAccountName is a neat choice in such cases.
Here is a small example:
$ADData = @'
"sAMAccountName","DisplayName"
"jlennon","John Lennon"
"gharrison","George Harrison"
"pmccartney","Paul McCartney"
"rstarr","Ringo Starr"
'@ |
ConvertFrom-Csv
$SPData = @'
"sAMAccountName","UniqueID"
"jlennon","1"
"gharrison","2"
"pmccartney","3"
"rstarr","4"
'@ |
ConvertFrom-Csv
$NewList =
foreach($User in $ADData){
[PSCustomObject]@{
sAMAccountName = $User.sAMAccountName
DisplayName = $User.DisplayName
UniqueID = ($SPData | Where-Object -Property 'sAMAccountName' -EQ -Value $User.sAMAccountName).UniqueID
}
}
$NewList
And the result would be the sAMAccountname you have in both lists, the DisplayName from the ADData and the UniqueID from the SPData:
sAMAccountName DisplayName UniqueID
-------------- ----------- --------
jlennon John Lennon 1
gharrison George Harrison 2
pmccartney Paul McCartney 3
rstarr Ringo Starr 4
Now … your code … assumed your code really starts in line 1 …
Line 3: I think it’s a bad idea to install a module inside of a function while you actually just want to use this module. Do you really need to install it every single time you run this code?
Line 4 and 5: To make function really re-usable you should not hard code values in it that could change. Make it a parameter of the function
Line 10 to 21: This syntax to create an object is very old. Nowadays we use PSCustomObjects.
Your function could look like this:
function Get-SPList {
param (
$SiteUrl,
$ListName
)
Connect-PnPOnline $SiteUrl
$SPlist = Get-PnPListItem -List $ListName -Fields 'ServiceAccount', 'LastPasswordSet', 'Enabled', 'Interactive', 'GUID'
foreach ($listItem in $SPlist) {
[PSCustomObject]@{
ServiceAccount = $listItem['ServiceAccount'].ToString()
LastPasswordSet = $listItem['LastPasswordSet'].ToString('yyyy-MM-dd')
Enabled = $listItem['Enabled']
Interactive = $listItem['Interactive']
ID = $listItem['ID']
}
}
}
Now if you want to have the result of this function in an array with the name $array2 you can call it like this:
$array2 = Get-SPList -SiteUrl 'Https://...' -ListName 'Whatever'
In your function Compare-Lists you use the variables $array and $array2 you defined in other functions. And you do the same with the variable $listItem in your line 43. That cannot work because variables you define in the scope of a function only exist in the scope of this very function. You could circumvent this by using global variables but that is considered very bad style and should be avoided. The proper approach would be to provide everything a function needs as input parameters of the function.
The same issue you have with your compared lists and your update function.
Then something general … you have 4 functions but you actually use every function only once. That does not make that much sense. We use functions for code we need more than once. 
I think you’d be better off not using functions in you script in this case.
I hope it helps a little bit.