Works on Excel files with Powershell

Here is a powershell script where it could "compare and update".
This particular powershell will look for the username and insert it from one file to the other.

* Adjust and use it in your own risk.


$strPath = "C:\s\library.csv"  # this is the main spreadsheet which we look for the username and update the password
$strPath2 = "C:\s\Year102016.csv" # this is the csv file which contains the username and password

$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $false

$workbook1 = $objExcel.Workbooks.Open($strPath)
$worksheet1 = $workbook1.sheets.item("library")
$intRowMax1 =  ($worksheet1.UsedRange.Rows).count

$workbook2 = $objExcel.Workbooks.Open($strPath2)
$worksheet2 = $workbook2.sheets.item("Year102016")
$intRowMax2 =  ($worksheet2.UsedRange.Rows).count


$colA = 1 # column contain the username
$colO = 15 # Where we need to insert the password

# 
#
Function checkAndAdd
{

        Param($username, $password)

        write-host "Second FOR Loop: " $intRow1 " Looking for username: " $username

        # Loop from Row 1 to the last Row
        for ($intRow1 = 1 ; $intRow1 -le $intRowMax1 ; $intRow1++) 
        {
            # read the username into $colA
            $colA = $worksheet1.cells.item($intRow1,1).value2 

            if ($colA -match $username)
            {
                Write-Host "Found username: " $username " insert password to column now."
                $worksheet1.cells.item($intRow1, $colO) = $password
                break
            } 
                
         } # ROW FOR LOOP
}



# READ the Year102016.csv row by row, pass in the Username, Password, to the other Excel file
# MAIN For Loop
#

Function ReadUsernamePassword
{ 
    # Loop from Row 2 to the last Row
    for ($intRow2 = 2; $intRow2 -le $intRowMax2 ; $intRow2++) 
    {
        # Make sure column 1 = username, column 8 = password
        $username = $worksheet2.cells.item($intRow2, 1).value2
        $password = $worksheet2.cells.item($intRow2, 8).value2

        
        write-host "MAIN For Loop: "$intRow2 " checking username: " $username " password: " $password 
        checkAndAdd $username $password

    } 
}    
#>


# Check 1 code only
# Beware the strPath file that you read/write to may need to change.

Function Check1Code
{
    Param($username, $password)
    checkAndAdd $username $password
}

## Uncomment this to Run Check1Code  
## 
## 
#
#Check1Code "abc1234" "password"

ReadUsernamePassword

      
$workbook1.SaveAs('C:\s\LibraryFINAL.csv') # output file 
$objexcel.quit()

My First Shell Script in OSX

#!/bin/sh
# Enable SSH
echo "Enabling SSH"
systemsetup -setremotelogin on
echo “Set computer name to this format eg: LRC-IMACXX, where xx is numbers.”
scutil --set HostName
ComputerName=$(HostName)
scutil --set LocalHostName $ComputerName
scutil --set ComputerName $ComputerName
echo “Computer name set to: “ $ComputerName
echo “Changing power preference”
sudo pmset -c ttyskeepawake 1
sudo pmset -c sleep 15
sudo pmset -c displaysleep 10
sudo pmset -c womp 1
sudo pmset -c halfdim 1
sudo pmset -c disksleep 10
echo “Schedule MAC wakeup at 8am and shutdown at 6pm everyday”
sudo pmset repeat shutdown MTWRF 18:00:00 wakeorpoweron MTWRF 08:00:00
echo “Set proxy”
sudo networksetup -setautoproxyurl Ethernet http://something.pac
sudo networksetup -setautoproxyurl Wi-Fi http://something.pac
echo “Joining Domain…”
sudo dsconfigad -f -a $ComputerName -domain domain.com -u username -p password
echo “Done”

to run this in terminal>
sudo sh scritpt.sh