Code from the Module:
function Clear-AllADPImportGlobalVariables {
Clear-Variable -Name AD* -Scope Global -Force
Clear-Variable -Name Log* -Scope Global -Force
Clear-Variable -Name CSV* -Scope Global -Force
Clear-Variable -Name Import* -Scope Global -Force
}
function Update-TimestampAllFileNames {
$global:AllFileNameTimestamp = $null
$global:AllFileNameTimestamp = Get-Date -Format 'yyyy-MM-dd-hh-mm-ss'
}
function Clear-UDUImportADPCSVtoADUploader {
$global:ADPUploadFrmData = $null
$global:ADPUploadFrmJSONBytes = $null
$global:ADPUploadFrmFileName = $null
$global:ADPUploadFrmFolderPath = $null
$global:ADPUploadFrmFPathPlusFName = $null
}
function New-UDUImportADPCSVtoADUploader {
$global:ADPUploadFrmFileNameTimestamp = $null
$global:ADPUploadFrmFileNameTimestamp = Get-Date -Format 'yyyy-MM-dd-hh-mm-ss'
$global:ADPUploadFrmData = $global:ADPCSVUploadBodyRawData | ConvertFrom-Json
$global:ADPUploadFrmJSONBytes = [System.Convert]::FromBase64String($global:ADPUploadFrmData.Data)
$global:ADPUploadFrmFileName = $global:ADPUploadFrmData.Name
$global:ADPUploadFrmFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\ADPData"
If (-not (Test-Path -Path $global:ADPUploadFrmFolderPath -ErrorAction SilentlyContinue)) {
# Folder does not exist, create it
New-Item -Path $global:ADPUploadFrmFolderPath -ItemType Directory -Force
}
$global:ADPUploadFrmFPathPlusFName = "$global:ADPUploadFrmFolderPath\$global:ADPUploadFrmFileNameTimestamp-$global:ADPUploadFrmFileName"
[System.IO.File]::WriteAllBytes($global:ADPUploadFrmFPathPlusFName, $global:ADPUploadFrmJSONBytes)
}
Function Clear-LogfileVariableInfo {
#Null out log file variables
#$global:LogfileRootFolderPath = $Null
$global:LogfileExportFileName = $null
$global:LogfileExportPathandName = $null
}
Function Update-LogfileVariableInfo {
$global:LogfileTimestamp = $null
$global:LogfileTimestamp = $global:AllFileNameTimestamp
$global:LogfileRootFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\ADPLogs\"
$global:LogfileExportFileName = 'ADPSync-Log-' + $global:LogfileTimestamp + '.txt'
$global:LogfileExportPathandName = $global:LogfileRootFolderPath + $global:LogfileExportFileName
}
Function Clear-ADPCSVFileVariableInfo {
#null out these variables
$global:ADPCSVDataRootFolderPath = $null
$global:ADPCSVLatestDataFile = $null
$global:ADPCSVLatestDataFileName = $null
#variables for CSV file handling
$global:ADPUserCSVData = $null
}
Function Update-ADPCSVFileVariableInfo {
#Parse for newest ADP file
$global:ADPCSVDataRootFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\ADPData\"
$global:ADPCSVLatestDataFile = Get-ChildItem $global:ADPCSVDataRootFolderPath -Filter *.csv | sort LastWriteTime | select -Last 1
$global:ADPCSVLatestDataFileName = $global:ADPCSVLatestDataFile.FullName
#commented to test using different file
$global:ADPUserCSVData = Import-Csv $global:ADPCSVLatestDataFileName
#This is the temp replacement
#$global:ADPUserCSVData = Import-Csv $global:ADPUploadFrmFPathPlusFName
}
function Clear-ADPSubmittedCSVHeaderComparison {
$global:ADPUserCSVDataMeasure = $null
#array for submitted file compare variables
$global:ADPCSVHeaderNamesObjCompareDif = @()
$global:ADPCSVHeaderNamesCompared = $null
#Array Headers that should be present in the submitted CSV
$global:ADPCSVHeaderNamesObjCompareRef = @()
$global:ADPCSVHeaderNamesObjCompareRef = @('Associate ID', 'File Number', 'Hire/Rehire Date', 'Home Department Code', 'Home Department Description', 'Job Title Description', 'Legal First Name', 'Legal Last Name', 'Location Description', 'Payroll Company Code', 'Personal Contact: Personal Mobile', 'Position ID', 'Position Status', 'Preferred or Chosen First Name', 'Professional Suffix Code', 'Pronouns', 'Reports To Associate ID', 'Reports To Name', 'Termination Date', 'Work Address: Address Line 1', 'Work Address: City', 'Work Address: State / Territory Code', 'Work Address: Zip / Postal Code', 'Work Contact: Work Email', 'Work Contact: Work Fax', 'Work Contact: Work Mobile', 'Work Contact: Work Phone', 'Worker Category Description')
}
function Update-ADPSubmittedCSVHeaderComparison {
$global:ADPUserCSVDataMeasure = $global:ADPUserCSVData | Measure-Object
$global:ADPCSVHeaderNamesObjCompareDif = ($global:ADPUserCSVData | Get-Member -MemberType NoteProperty -ErrorAction SilentlyContinue).Name
try {
$global:ADPCSVHeaderNamesCompared = Compare-Object -ReferenceObject $global:ADPCSVHeaderNamesObjCompareRef -DifferenceObject $global:ADPCSVHeaderNamesObjCompareDif -CaseSensitive -PassThru
}
catch {
}
}
Function Clear-ADPUserCSVVariableInfo {
#Null variables used to hold csv values
$global:ADPUserAssocID = $null
$global:ADPUserJobTitle = $null
$global:ADPUserFileNumber = $null
$global:ADPUserOffice = $null
$global:ADPUserDepartment4Digit = $null
$global:ADPUserDepartmentDescript = $null
$global:ADPUserReportToManager = $null
$global:ADPUserWorkOfficeNum = $null
$global:ADPUserWorkMobileNum = $null
$global:ADPUserWorkFacsimileNum = $null
$global:ADPUserStreetAddress = $null
$global:ADPUserCity = $null
$global:ADPUserState = $null
$global:ADPUserPostalCode = $null
$global:ADPUserHireDate = $null
$global:ADPUserTermDate = $null
#Declare array for list of users to export to CSV
$global:ADPProcessedUserAssocIdArray = @()
}
Function Update-ADPUserCSVVariableInfo {
$global:ADPUserAssocID = $global:ADPUserCSV.'Associate ID'
$global:ADPUserJobTitle = $global:ADPUserCSV.'Job Title Description'
$global:ADPUserFileNumber = $global:ADPUserCSV.'File Number'
$global:ADPUserOffice = $global:ADPUserCSV.'Location Description'
$global:ADPUserDepartment4Digit = $global:ADPUserCSV.'Home Department Code'
$global:ADPUserDepartmentDescript = $global:ADPUserCSV.'Home Department Description'
$global:ADPUserReportToManager = $global:ADPUserCSV.'Reports To Associate ID'
$global:ADPUserWorkOfficeNum = $global:ADPUserCSV.'Work Contact: Work Phone'
$global:ADPUserWorkMobileNum = $global:ADPUserCSV.'Work Contact: Work Mobile'
$global:ADPUserWorkFacsimileNum = $global:ADPUserCSV.'Work Contact: Work Fax'
$global:ADPUserStreetAddress = $global:ADPUserCSV.'Work Address: Address Line 1'
$global:ADPUserCity = $global:ADPUserCSV.'Work Address: City'
$global:ADPUserState = $global:ADPUserCSV.'Work Address: State / Territory Code'
$global:ADPUserPostalCode = $global:ADPUserCSV.'Work Address: Zip / Postal Code'
$global:ADPUserHireDate = $global:ADPUserCSV.'Hire/Rehire Date'
$global:ADPUserTermDate = $global:ADPUserCSV.'Termination Date'
#format FileNumber and Dept Code
if (($global:ADPUserDepartment4Digit).tostring().length -gt 4) { $global:ADPUserDepartment4Digit = $global:ADPUserDepartment4Digit -replace '^0+(?=[^.])', '' }
if (($global:ADPUserFileNumber).tostring().length -gt 5) { $global:ADPUserFileNumber = $global:ADPUserFileNumber -replace '^0+(?=[^.])', '' }
#Build AssocID Array
$global:ADPProcessedUserAssocIdArray += $global:ADPUserAssocID
}
function Clear-ADUserVariableInfo {
#null pre and post user array dumps
$global:CSVComparisonPreADPDataImport = @()
$global:CSVComparisonPostADPDataImport = @()
#Null variable that holds user to process
$global:ADUserActDirData = $null
#null Attributes for handling a users manager setting
$global:ADPADUserReportsToManagerDistName = $null
#Null sub-variables that holds user specific sub-variables
$global:ADUserEmployeeID = $null
$global:ADUserPrincipalName = $null
$global:ADUserAccountExpirationDate = $null
$global:ADUserJobTitle = $null
$global:ADUserDepartmentDescript = $null
$global:ADUserPDON = $null
$global:ADUserWorkOfficeNum = $null
$global:ADUserWorkMobileNum = $null
$global:ADUserWorkFacsimileNum = $null
$global:ADUserStreetAddress = $null
$global:ADUserCity = $null
$global:ADUserState = $null
$global:ADUserPostalCode = $null
#extensionAttribute5 is the users Department Description; until the dynamic groups are updated this has to stay numeric
$global:ADUserExtAttrib5 = $null
#extensionAttribute6 is the users ADP File Number
$global:ADUserExtAttrib6 = $null
#extensionAttribute7 is the users Hire Date
$global:ADUserExtAttrib7 = $null
#extensionAttribute8 is the users Termination Date
$global:ADUserExtAttrib8 = $null
#extensionAttribute15 is the users Telephone Number attribute but formatted to be used in the email signature
$global:ADUserExtAttrib15 = $null
}
Function Update-ADUserADManagerVariableInfo {
$global:ADUserADManagerPulledFromAD = $null
try {
$global:ADUserADManagerPulledFromAD = Get-ADUser -LDAPFilter “(employeeID=$global:ADPUserReportToManager)” -Properties sAMAccountName, userPrincipalName, DistinguishedName | Select-Object sAMAccountName, userPrincipalName, DistinguishedName
}
catch {
"PROCESSING: $global:ADUserPrincipalName has no manager set in the AD." | Out-File -FilePath $global:LogfileExportPathandName -NoClobber -Append
}
}
Function Update-ADUserVariableInfo {
$global:ADUserActDirData = Get-ADUser -LDAPFilter “(employeeID=$global:ADPUserAssocID)” -Properties sAMAccountName, employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 -Server kvc.org | Select-Object -Property sAMAccountName, userPrincipalName, employeeID, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15
$global:ADPADUserReportsToManagerDistName = $global:ADUserActDirData.manager
$global:ADUserEmployeeID = $global:ADUserActDirData.employeeID
$global:ADUserPrincipalName = $global:ADUserActDirData.userPrincipalName
$global:ADUserAccountExpirationDate = $global:ADUserActDirData.accountExpirationDate
$global:ADUserJobTitle = $global:ADUserActDirData.Title
$global:ADUserDepartmentDescript = $global:ADUserActDirData.Department
$global:ADUserPDON = $global:ADUserActDirData.physicalDeliveryOfficeName
$global:ADUserWorkOfficeNum = $global:ADUserActDirData.telephoneNumber
$global:ADUserWorkMobileNum = $global:ADUserActDirData.mobile
$global:ADUserWorkFacsimileNum = $global:ADUserActDirData.facsimileTelephoneNumber
$global:ADUserStreetAddress = $global:ADUserActDirData.StreetAddress
$global:ADUserCity = $global:ADUserActDirData.city
$global:ADUserState = $global:ADUserActDirData.st
$global:ADUserPostalCode = $global:ADUserActDirData.postalCode
$global:ADUserExtAttrib5 = $global:ADUserActDirData.extensionAttribute5
$global:ADUserExtAttrib6 = $global:ADUserActDirData.extensionAttribute6
$global:ADUserExtAttrib7 = $global:ADUserActDirData.extensionAttribute7
$global:ADUserExtAttrib8 = $global:ADUserActDirData.extensionAttribute8
$global:ADUserExtAttrib15 = $global:ADUserActDirData.extensionAttribute15
#$global:CSVComparisonPreADPDataImport += $global:ADUserActDirData
}
Function Clear-AllWorkTelephoneNumbers {
#Null variables for phone number fomatting
$global:ADPUserWorkOfficeNumFormatted = $null
$global:ADPUserWorkMobileNumFormatted = $null
$global:ADPUserWorkFacsimileNumFormatted = $null
$global:ADPUserWorkOfficeNumFormattedForSignature = $null
}
Function Format-AllWorkTelephoneNumbers {
#working format command but a bit complicated
$global:ADPUserWorkOfficeNumFormatted = $global:ADPUserWorkOfficeNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '+1$1$2$3'
$global:ADPUserWorkMobileNumFormatted = $global:ADPUserWorkMobileNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
$global:ADPUserWorkFacsimileNumFormatted = $global:ADPUserWorkFacsimileNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
$global:ADPUserWorkOfficeNumFormattedForSignature = $global:ADPUserWorkOfficeNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
}
Function Clear-ADPPreADCSVFileName {
#null out Pre-Import Variables
$global:CSVPreComparisonRootFolderPath = $null
$global:CSVPreComparisonFileName = $null
$global:CSVPreComparisonPathandName = $null
}
Function New-ADPPreADCSVFileName {
$global:CSVPreCompFileTimestamp = $null
$global:CSVPreCompFileTimestamp = $global:AllFileNameTimestamp
#set Pre-Import path and file name info
$global:CSVPreComparisonRootFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\Pre-ADPtoADUserUpdateRecord\"
$global:CSVPreComparisonFileName = 'Pre-ProcessedADUserAttributeValues-' + $global:CSVPreCompFileTimestamp + '.csv'
$global:CSVPreComparisonPathandName = $global:CSVPreComparisonRootFolderPath + $global:CSVPreComparisonFileName
}
Function Clear-ADPPostADCSVFileName {
#null out Post-Import Variables
$global:CSVPostComparisonRootFolderPath = $null
$global:CSVPostComparisonFileName = $null
$global:CSVPostComparisonPathandName = $null
}
Function New-ADPPostADCSVFileName {
$global:CSVPostCompFileTimestamp = $null
$global:CSVPostCompFileTimestamp = $global:AllFileNameTimestamp
#set Post-Import path and file name info
$global:CSVPostComparisonRootFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\Post-ADPtoADUserUpdateRecord\"
$global:CSVPostComparisonFileName = 'Post-ProcessedADUserAttributeValues-' + $global:CSVPostCompFileTimestamp + '.csv'
$global:CSVPostComparisonPathandName = $global:CSVPostComparisonRootFolderPath + $global:CSVPostComparisonFileName
}
Function Clear-ADPCSVComparisonResultsFileNames {
#null out Post-Import Variables
$global:CSVCompareResultsRootFolderPath = $null
$global:CSVCompareResultsFileName = $null
$global:CSVCompareResultsPathandName = $null
}
Function New-ADPCSVComparisonResultsFileNames {
$global:CSVCompareResultFileTimestamp = $null
$global:CSVCompareResultFileTimestamp = $global:AllFileNameTimestamp
#set Pre-Import path and file name info
$global:CSVCompareResultsRootFolderPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\ADPADChangeComparisonResults\"
$global:CSVCompareResultsFileName = 'ProcessedADUserAttributeValuesCompared-' + $global:CSVCompareResultFileTimestamp + '.csv'
$global:CSVCompareResultsPathandName = $global:CSVCompareResultsRootFolderPath + $global:CSVCompareResultsFileName
}
Function New-ADPADUpdatesPreImportArrayBuildForRef {
$PreProcessedADUser = $null
foreach ($PreProcessedADUser in $global:CSVComparisonPreADPDataImport) {
$PreProcessedADUser | Select-Object -Property employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Sort-Object -Property userPrincipalName | Export-Csv -Path $global:CSVPreComparisonPathandName -NoTypeInformation -NoClobber -Append
}
}
Function New-ADPADUpdatesPostImportArrayBuildForDif {
$PostProcessedADUser = $null
foreach ($PostProcessedADUser in $global:CSVComparisonPostADPDataImport) {
$PostProcessedADUser | Select-Object -Property employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Sort-Object -Property userPrincipalName | Export-Csv -Path $global:CSVPostComparisonPathandName -NoTypeInformation -NoClobber -Append
}
}
Function Clear-ADPPreAndPostADAttributeValues {
$global:CSVPreRefValCompPostDifVals = @()
$global:CSVCompareResultsPSOValues = $null
$global:CSVArrayOfCompareResults = @()
$global:CSVPreRecordIndexValue = 0
$global:CSVPostRecordIndexValue = 0
$global:ImportEmployeeTitleChange = $null
$global:ImportEmployeeDepartmentChange = $null
$global:ImportEmployeephysDelivOffNameChange = $null
$global:ImportEmployeeTelephoneNumChange = $null
$global:ImportEmployeeMobileNumChange = $null
$global:ImportEmployeeFaxNumChange = $null
$global:ImportEmployeeStreetAddrChange = $null
$global:ImportEmployeeCityChange = $null
$global:ImportEmployeeStateChange = $null
$global:ImportEmployeePostalCodeChange = $null
$global:ImportEmployeeManagerChange = $null
$global:ImportEmployeeAccountExpirationChange = $null
$global:ImportEmployeeextAttrib5Change = $null
$global:ImportEmployeeextAttrib6Change = $null
$global:ImportEmployeeextAttrib7Change = $null
$global:ImportEmployeeextAttrib8Change = $null
$global:ImportEmployeeextAttrib15Change = $null
}
Function Compare-ADPPreAndPostADAttributeValues {
$CSVCompareResult = $null
$CSVPreComparisonFileImport = $null
$CSVPostComparisonFileImport = $null
$CSVPreComparisonFileImport = Import-Csv -Path $global:CSVPreComparisonPathandName
$CSVPostComparisonFileImport = Import-Csv -Path $global:CSVPostComparisonPathandName
$global:CSVPreRefValCompPostDifVals = Compare-Object -ReferenceObject @($CSVPreComparisonFileImport | Select-Object) -DifferenceObject @($CSVPostComparisonFileImport | Select-Object) -Property employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 -CaseSensitive -PassThru | Where-Object { $_.SideIndicator -eq "=>" }
Foreach ($CSVCompareResult in $global:CSVPreRefValCompPostDifVals) {
$global:CSVPreRecordIndexValue = [Array]::IndexOf($CSVPreComparisonFileImport.employeeID, $CSVCompareResult.employeeID)
$global:CSVPostRecordIndexValue = [Array]::IndexOf($CSVPostComparisonFileImport.employeeID, $CSVCompareResult.employeeID)
$global:ImportEmployeeTitleChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].title) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].title)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].title } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].title + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].title }
$global:ImportEmployeeDepartmentChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].department) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].department)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].department } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].department + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].department }
$global:ImportEmployeephysDelivOffNameChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].physicalDeliveryOfficeName) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].physicalDeliveryOfficeName)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].physicalDeliveryOfficeName } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].physicalDeliveryOfficeName + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].physicalDeliveryOfficeName }
$global:ImportEmployeeTelephoneNumChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].telephoneNumber) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].telephoneNumber)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].telephoneNumber } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].telephoneNumber + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].telephoneNumber }
$global:ImportEmployeeMobileNumChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].mobile) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].mobile)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].mobile } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].mobile + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].mobile }
$global:ImportEmployeeFaxNumChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].facsimileTelephoneNumber) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].facsimileTelephoneNumber)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].facsimileTelephoneNumber } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].facsimileTelephoneNumber + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].facsimileTelephoneNumber }
$global:ImportEmployeeStreetAddrChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].streetAddress) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].streetAddress)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].streetAddress } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].streetAddress + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].streetAddress }
$global:ImportEmployeeCityChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].city) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].city)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].city } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].city + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].city }
$global:ImportEmployeeStateChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].st) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].st)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].st } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].st + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].st }
$global:ImportEmployeePostalCodeChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].postalCode) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].postalCode)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].postalCode } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].postalCode + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].postalCode }
$global:ImportEmployeeManagerChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].manager) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].manager)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].manager } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].manager + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].manager }
$global:ImportEmployeeAccountExpirationChange = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].accountExpirationDate) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].accountExpirationDate)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].accountExpirationDate } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].accountExpirationDate + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].accountExpirationDate }
$global:ImportEmployeeextAttrib5Change = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute5) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute5)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute5 } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute5 + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute5 }
$global:ImportEmployeeextAttrib6Change = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute6) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute6)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute6 } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute6 + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute6 }
$global:ImportEmployeeextAttrib7Change = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute7) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute7)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute7 } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute7 + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute7 }
$global:ImportEmployeeextAttrib8Change = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute8) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute8)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute8 } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute8 + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute8 }
$global:ImportEmployeeextAttrib15Change = if (($CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute15) -eq ($CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute15)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute15 } else { "Previous Value: " + $CSVPreComparisonFileImport[$global:CSVPreRecordIndexValue].extensionAttribute15 + " | Updated Value: " + $CSVPostComparisonFileImport[$global:CSVPostRecordIndexValue].extensionAttribute15 }
$global:CSVCompareResultsPSOValues = [pscustomobject][ordered] @{
employeeID = $CSVCompareResult.employeeID
userPrincipalName = $CSVCompareResult.userPrincipalName
title = $global:ImportEmployeeTitleChange
department = $global:ImportEmployeeDepartmentChange
physicalDeliveryOfficeName = $global:ImportEmployeephysDelivOffNameChange
telephonenumber = $global:ImportEmployeeTelephoneNumChange
mobile = $global:ImportEmployeeMobileNumChange
facsimileTelephoneNumber = $global:ImportEmployeeFaxNumChange
streetAddress = $global:ImportEmployeeStreetAddrChange
city = $global:ImportEmployeeCityChange
st = $global:ImportEmployeeStateChange
postalCode = $global:ImportEmployeePostalCodeChange
manager = $global:ImportEmployeeManagerChange
accountExpirationDate = $global:ImportEmployeeAccountExpirationChange
extensionAttribute5 = $global:ImportEmployeeextAttrib5Change
extensionAttribute6 = $global:ImportEmployeeextAttrib6Change
extensionAttribute7 = $global:ImportEmployeeextAttrib7Change
extensionAttribute8 = $global:ImportEmployeeextAttrib8Change
extensionAttribute15 = $global:ImportEmployeeextAttrib15Change
}
$global:CSVArrayOfCompareResults += $global:CSVCompareResultsPSOValues
$global:CSVCompareResultsPSOValues | Select-Object employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Export-Csv -Path $global:CSVCompareResultsPathandName -Append -NoClobber -NoTypeInformation
}
}