Helper function to replace data in a CSV file

Just a quick share as I needed this for something, this function will replace values in a CSV file. It takes the desired column(s) and value(s) to search for and a new value and desired target column as required parameters.

function update-csvColumn{
    Param(
        [Parameter(Mandatory=$true)]$csvContents, #input original CSV file contents here (use import-csv first)
        [Parameter(Mandatory=$true)][Array]$searchForColumns, #names of the columns you want to base your search on
        [Parameter(Mandatory=$true)][Array]$searchForValues, #replace rows in $searchForColumn that match these values (in same order!)
        [Parameter(Mandatory=$true)]$replaceColumn, #set this column to what you specified in $newValue
        [Parameter(Mandatory=$true)]$newValue #the new value you wish to set $searchForColumn or $replaceColumn to
    )
    if($searchForColumns.Count -ne $searchForValues.Count) {Throw "You must supply an equal number of columns and values to match on"}
    for($i = 0; $i -lt $csvContents.Count; $i++){
        $replace = $True
        for($c = 0; $c -lt $searchForColumns.Count; $c++){
            if($csvContents[$i].$($searchForColumns[$c]) -ne $searchForValues[$c]){
                $replace = $False
            }
        }
        if($replace){
            $csvContents[$i].$replaceColumn = $newValue
        }
    }
    return $csvContents
}

SAP SuccessFactors to Active Directory Sync (disabled users)

For a customer that is using SuccessFactors to manage their employees / contractees, I wrote a script that will disable the AD accounts of any person that is disabled in SuccessFactors.

I expect you’ll have working knowledge on how to configure SF PerformanceManager to export the users you wish to disable to a CSV file on the sFTP server SF provides for you.

With that, you should be able to configure the script. If you wish, the script will provide you with a full report in your email, for example:

Get it @ Gitlab directly:  https://gitlab.com/Lieben/assortedFunctions/tree/master/SuccessFactors%20and%20SAP