@adam I realy appreciate you answering my question. My guess is you get it a lot. And after more testing, I do think adding the $ProgressPreference = ‘SilentlyContinue’ to the beginning of the Dashboard\App code is working:
$ProgressPreference = 'SilentlyContinue'
$Navigation = @(
New-UDListItem -Label 'Active Directory Powershell Tools' -OnClick {
Invoke-UDRedirect -Url '/ADPowershellTools'
}
New-UDListItem -Label 'Import ADP CSV to AD' -OnClick {
Invoke-UDRedirect -Url '/ImportADPCSVtoAD'
}
)
New-UDApp -Title 'MS AD Dashboard (PowerShell Universal)' -Pages @(
Get-UDPage -Name 'Active Directory Powershell Tools'
Get-UDPage -Name 'Import ADP CSV to AD'
) -Navigation $Navigation
And here is the environments config.
New-PSUEnvironment -Name "PShell 7 Active Directory Dashboard Environment" -Version "7.3.9" -Path "C:\Program Files\PowerShell\7\pwsh.exe" -Modules @('ActiveDirectory', 'Russ.ADTools.Dashboard.ADP.Functions', 'Russ.Connection.MGGraph', 'Microsoft.Graph.Users', 'Russ.ADTools.Maintenance.ADP.Functions') -Variables @('*') -MaxRunspaces 3 -Description "Environment for the production dashboard AD Tool"
And I believe I have it setup so it should only instigate a new runspace when more than one user opens the app in a different browser. (Let me know if that isn’t the case.)
I did however make another run today and though the bulk of the script finished (script is wrapped in a UDDynamic btw), during the last foreach loop, it seems to have failed half-way through. Though it did run the final block that sends an email.
If I understand correctly and as long as the page is open and the mouse is occasionally moving, the default session timer keeps resetting to the default amount of time to countdown from. Even though I was doing this, whatever about my code seems to have caused another runspace to spin up and interrupt the script.
It is worth noting that this was during roughly the 3rd file I was processing and there is a finish button the user has to click after a file is processed and part of that button’s actions, besides nulling out variables, it starts the user at the beginning with a UDRedirect:
Invoke-UDRedirect -Url '/ImportADPCSVtoAD'
Again, I appreciate you responding in general but if you could tell me what, if anything, there is that can be done to gurantee my script won’t get inturruped, I’d really appreciate it.
It’s more lines than are allowed for a forum post but here is my code truncated:
Show-UDModal -Footer {
New-UDButton -Id 'UDBTNADPProcessAnother' -OnClick {
$session:ADPUserCSVData = $null
$page:ADPCSVUploadBodyRawData = $null
$page:ADPUploadFrmData = $null
$page:ADPUploadFrmFPathPlusFName = $null
$page:ADPUploadFrmFileName = $null
$page:ADPUploadPathValidation = $null
$page:ADPUploadFileValidation = $null
Invoke-UDRedirect -Url '/ImportADPCSVtoAD'
Hide-UDModal
} -Text 'DO NOT CLICK'
} -Content {
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: ADP Import Process Started by User: $User" -Force
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: The ADP CSV file submitted for import passed all validation tests. The users submitted will be updated." -Force
New-UDTypography -Text 'ADP Data is Now Importing' -Variant h3 -Style @{ color = 'green' }
#null out Pre-Import Variables
$page:CSVPreCompFileTimestamp = $null
$session:CSVPreComparisonPathandName = $null
#null out Post-Import Variables
$page:CSVPostCompFileTimestamp = $null
$session:CSVPostComparisonPathandName = $null
#set Pre-Import path and file name info
$page:CSVPreCompFileTimestamp = $cache:ADPImportFunctionVariablelTimestamp
$session:CSVPreComparisonPathandName = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\Pre-ADPtoADUserUpdateRecord\Pre-ProcessedADUserAttributeValues-$page:CSVPreCompFileTimestamp.csv"
#set Post-Import path and file name info
$page:CSVPostCompFileTimestamp = $cache:ADPImportFunctionVariablelTimestamp
$session:CSVPostComparisonPathandName = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\Post-ADPtoADUserUpdateRecord\Post-ProcessedADUserAttributeValues-$page:CSVPostCompFileTimestamp.csv"
$page:ADPNumberOfUsersSubmitted = 0
$page:ADPNumberOfUsersSubmitted = $page:ADPUserCSVDataMeasure
$page:ADPNumberOfCurrentUserBeingProcessed = 0
New-UDDynamic -Id 'UDDYADPImportProgressStatus' -Content {
$page:ADPImportProgressPercent = 0
$page:ADPImportProgressPercent = ($page:ADPNumberOfCurrentUserBeingProcessed / $page:ADPNumberOfUsersSubmitted) * 100
$page:ADPImportProgressPercent = [math]::Round($page:ADPImportProgressPercent)
$page:ADPImportProgressPercentCosmetic = $null
$page:ADPImportProgressPercentCosmetic = ($page:ADPNumberOfCurrentUserBeingProcessed / $page:ADPNumberOfUsersSubmitted).tostring("P")
New-UDTypography -Content { "The $page:ADPNumberOfUsersSubmitted users you submitted for update are now processing." } -Variant h4
New-UDProgress -PercentComplete $page:ADPImportProgressPercent
New-UDTypography -Content { "Percent Complete: $page:ADPImportProgressPercentCosmetic" } -Variant h4
}
New-UDDynamic -Id 'UDDYADPImportForEach' -Content {
foreach ($session:ADPUserCSV in $session:ADPUserCSVData) {
#reset all variables used to hold data from ADP CSV
TRUNCATED
#immediately populate those attributes with data from csv
TRUNCATED
#reset all variables used to hold data Users current AD Data
TRUNCATED
#immediately set those variables with the currently processing users AD attribute values
$session:ADUserActDirData = Get-ADUser -LDAPFilter “(employeeID=$session: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
$session:ADPADUserReportsToManagerDistName = $session:ADUserActDirData.manager
$session:ADUserEmployeeID = $session:ADUserActDirData.employeeID
$session:ADUserPrincipalName = $session:ADUserActDirData.userPrincipalName
$session:ADUserAccountExpirationDate = $session:ADUserActDirData.accountExpirationDate
$session:ADUserJobTitle = $session:ADUserActDirData.Title
$session:ADUserDepartmentDescript = $session:ADUserActDirData.Department
$session:ADUserPDON = $session:ADUserActDirData.physicalDeliveryOfficeName
$session:ADUserWorkOfficeNum = $session:ADUserActDirData.telephoneNumber
$session:ADUserWorkMobileNum = $session:ADUserActDirData.mobile
$session:ADUserWorkFacsimileNum = $session:ADUserActDirData.facsimileTelephoneNumber
$session:ADUserStreetAddress = $session:ADUserActDirData.StreetAddress
$session:ADUserCity = $session:ADUserActDirData.city
$session:ADUserState = $session:ADUserActDirData.st
$session:ADUserPostalCode = $session:ADUserActDirData.postalCode
$session:ADUserExtAttrib5 = $session:ADUserActDirData.extensionAttribute5
$session:ADUserExtAttrib6 = $session:ADUserActDirData.extensionAttribute6
$session:ADUserExtAttrib7 = $session:ADUserActDirData.extensionAttribute7
$session:ADUserExtAttrib8 = $session:ADUserActDirData.extensionAttribute8
$session:ADUserExtAttrib15 = $session:ADUserActDirData.extensionAttribute15
try {
$session:ADUserADManagerPulledFromAD = Get-ADUser -LDAPFilter “(employeeID=$session:ADPUserReportToManager)” -Properties sAMAccountName, userPrincipalName, DistinguishedName | Select-Object sAMAccountName, userPrincipalName, DistinguishedName
}
catch {
Add-Content -Path $session:LogfileExportPathandName -Value "PROCESSING: $session:ADUserPrincipalName has no manager set in the AD." -Force
}
#Clear variables used to hold the phone numbers from ADP then properly format them
#there attributes that hold the non formatted numbers are in the other functions
#Null variables for phone number fomatting
$session:ADPUserWorkOfficeNumFormatted = $null
$session:ADPUserWorkMobileNumFormatted = $null
$session:ADPUserWorkFacsimileNumFormatted = $null
$session:ADPUserWorkOfficeNumFormattedForSignature = $null
#working format command but a bit complicated
$session:ADPUserWorkOfficeNumFormatted = $session:ADPUserWorkOfficeNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '+1$1$2$3'
$session:ADPUserWorkMobileNumFormatted = $session:ADPUserWorkMobileNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
$session:ADPUserWorkFacsimileNumFormatted = $session:ADPUserWorkFacsimileNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
$session:ADPUserWorkOfficeNumFormattedForSignature = $session:ADPUserWorkOfficeNum -replace "[^0-9]", "" -replace "^1(\d{10})$", '$1' -replace "(\d{3})(\d{3})(\d{4})", '$1-$2-$3'
#write users AD values to a CSV before the change
try {
#Build a Pre Import User list with attrib values CSV doc for the compare
Get-ADUser -LDAPFilter “(employeeID=$session:ADPUserAssocID)” -Properties sAMAccountName, employeeID, userPrincipalName, displayName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Select-Object sAMAccountName, employeeID, userPrincipalName, displayName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Export-Csv -Path $session:CSVPreComparisonPathandName -NoTypeInformation -NoClobber -Append
}
catch {
Add-Content -Path $session:LogfileExportPathandName -Value "ERROR: There was a problem polling the following users Pre-Update Attributes: $session:ADUserPrincipalName The error will be logged. Please review the SYSTEMERROR on the next line." -Force
Add-Content -Path $session:LogfileExportPathandName -Value "SYSTEMERROR: $_" -Force
}
#commit all the data that is detected to need an update to AD unless they are empty
Add-Content -Path $session:LogfileExportPathandName -Value "PROCESSING: $session:ADUserPrincipalName ..." -Force
#Process Users Job Title
if ($session:ADPUserJobTitle -eq '') {
Add-Content -Path $session:LogfileExportPathandName -Value "BLANK: The Users Job Title in ADP is blank. No changes will be made to the user's Job Title attribute value." -Force
}
elseif ($session:ADPUserJobTitle -ne $session:ADUserActDirData.title) {
try {
Set-ADUser -Identity $session:ADUserActDirData.sAMAccountName -Title $session:ADPUserJobTitle -Server kvc.org
Add-Content -Path $session:LogfileExportPathandName -Value "UPDATING: Title $session:ADUserJobTitle will be overwritten with value $session:ADPUserJobTitle" -Force
}
catch {
Add-Content -Path $session:LogfileExportPathandName -Value "ERROR: There was a problem updating the following user: $session:ADUserPrincipalName The script was unable to update the users title attribute value with the following data: $session:ADPUserJobTitle Please review the SYSTEMERROR on the next line." -Force
Add-Content -Path $session:LogfileExportPathandName -Value "SYSTEMERROR: $_" -Force
}
}
else {
Add-Content -Path $session:LogfileExportPathandName -Value "NOCHANGE: The Users ADP Job Title information in ADP already matches the AD objects Title attribute value: ADP Value = $session:ADPUserJobTitle <==> AD Value = $session:ADUserJobTitle" -Force
}
TRUNCATED
TRUNCATED
TRUNCATED
}
#CODE THAT GETS INTURRUPTED
$page:CSVCompareResultFileTimestamp = $null
$page:CSVCompareResultsPath = $null
$page:CSVCompareResultsPathandNameSuccess = $null
#set Pre-Import path and file name info
$page:CSVCompareResultFileTimestamp = $cache:ADPImportFunctionVariablelTimestamp
$page:CSVCompareResultsPath = "$env:SystemDrive\Temp\PShellUniversal\ADPFiles\ADPADChangeComparisonResults"
$page:CSVCompareResultsPathandNameSuccess = "$page:CSVCompareResultsPath\ProcessedADUserAttributeValuesCompared-$page:CSVCompareResultFileTimestamp.csv"
#null out comparison variables
$CSVPreRefValCompPostDifVals = @()
$page:CSVCompareResultsPSOValues = $null
$CSVArrayOfCompareResults = @()
$page:CSVPreRecordIndexValue = 0
$page:CSVPostRecordIndexValue = 0
$page:ImportEmployeeTitleChange = $null
$page:ImportEmployeeDepartmentChange = $null
$page:ImportEmployeephysDelivOffNameChange = $null
$page:ImportEmployeeTelephoneNumChange = $null
$page:ImportEmployeeMobileNumChange = $null
$page:ImportEmployeeFaxNumChange = $null
$page:ImportEmployeeStreetAddrChange = $null
$page:ImportEmployeeCityChange = $null
$page:ImportEmployeeStateChange = $null
$page:ImportEmployeePostalCodeChange = $null
$page:ImportEmployeeManagerChange = $null
$page:ImportEmployeeAccountExpirationChange = $null
$page:ImportEmployeeextAttrib5Change = $null
$page:ImportEmployeeextAttrib6Change = $null
$page:ImportEmployeeextAttrib7Change = $null
$page:ImportEmployeeextAttrib8Change = $null
$page:ImportEmployeeextAttrib15Change = $null
#Pre and Post value comparison code
$CSVCompareResult = $null
$CSVPreComparisonFileImport = $null
$CSVPostComparisonFileImport = $null
$CSVPreComparisonFileImport = Import-Csv -Path $session:CSVPreComparisonPathandName
$CSVPostComparisonFileImport = Import-Csv -Path $session:CSVPostComparisonPathandName
$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 $CSVPreRefValCompPostDifVals) {
$page:CSVPreRecordIndexValue = [Array]::IndexOf($CSVPreComparisonFileImport.employeeID, $CSVCompareResult.employeeID)
$page:CSVPostRecordIndexValue = [Array]::IndexOf($CSVPostComparisonFileImport.employeeID, $CSVCompareResult.employeeID)
$page:ImportEmployeeTitleChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].title) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].title)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].title } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].title + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].title }
$page:ImportEmployeeDepartmentChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].department) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].department)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].department } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].department + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].department }
$page:ImportEmployeephysDelivOffNameChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].physicalDeliveryOfficeName) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].physicalDeliveryOfficeName)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].physicalDeliveryOfficeName } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].physicalDeliveryOfficeName + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].physicalDeliveryOfficeName }
$page:ImportEmployeeTelephoneNumChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].telephoneNumber) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].telephoneNumber)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].telephoneNumber } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].telephoneNumber + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].telephoneNumber }
$page:ImportEmployeeMobileNumChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].mobile) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].mobile)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].mobile } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].mobile + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].mobile }
$page:ImportEmployeeFaxNumChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].facsimileTelephoneNumber) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].facsimileTelephoneNumber)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].facsimileTelephoneNumber } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].facsimileTelephoneNumber + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].facsimileTelephoneNumber }
$page:ImportEmployeeStreetAddrChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].streetAddress) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].streetAddress)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].streetAddress } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].streetAddress + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].streetAddress }
$page:ImportEmployeeCityChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].city) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].city)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].city } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].city + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].city }
$page:ImportEmployeeStateChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].st) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].st)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].st } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].st + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].st }
$page:ImportEmployeePostalCodeChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].postalCode) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].postalCode)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].postalCode } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].postalCode + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].postalCode }
$page:ImportEmployeeManagerChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].manager) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].manager)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].manager } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].manager + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].manager }
$page:ImportEmployeeAccountExpirationChange = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].accountExpirationDate) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].accountExpirationDate)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].accountExpirationDate } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].accountExpirationDate + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].accountExpirationDate }
$page:ImportEmployeeextAttrib5Change = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute5) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute5)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute5 } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute5 + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute5 }
$page:ImportEmployeeextAttrib6Change = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute6) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute6)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute6 } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute6 + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute6 }
$page:ImportEmployeeextAttrib7Change = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute7) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute7)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute7 } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute7 + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute7 }
$page:ImportEmployeeextAttrib8Change = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute8) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute8)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute8 } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute8 + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute8 }
$page:ImportEmployeeextAttrib15Change = if (($CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute15) -eq ($CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute15)) { "Value Did Not Change: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute15 } else { "Previous Value: " + $CSVPreComparisonFileImport[$page:CSVPreRecordIndexValue].extensionAttribute15 + " | Updated Value: " + $CSVPostComparisonFileImport[$page:CSVPostRecordIndexValue].extensionAttribute15 }
$page:CSVCompareResultsPSOValues = [pscustomobject][ordered] @{
employeeID = $CSVCompareResult.employeeID
userPrincipalName = $CSVCompareResult.userPrincipalName
title = $page:ImportEmployeeTitleChange
department = $page:ImportEmployeeDepartmentChange
physicalDeliveryOfficeName = $page:ImportEmployeephysDelivOffNameChange
telephonenumber = $page:ImportEmployeeTelephoneNumChange
mobile = $page:ImportEmployeeMobileNumChange
facsimileTelephoneNumber = $page:ImportEmployeeFaxNumChange
streetAddress = $page:ImportEmployeeStreetAddrChange
city = $page:ImportEmployeeCityChange
st = $page:ImportEmployeeStateChange
postalCode = $page:ImportEmployeePostalCodeChange
manager = $page:ImportEmployeeManagerChange
accountExpirationDate = $page:ImportEmployeeAccountExpirationChange
extensionAttribute5 = $page:ImportEmployeeextAttrib5Change
extensionAttribute6 = $page:ImportEmployeeextAttrib6Change
extensionAttribute7 = $page:ImportEmployeeextAttrib7Change
extensionAttribute8 = $page:ImportEmployeeextAttrib8Change
extensionAttribute15 = $page:ImportEmployeeextAttrib15Change
}
$CSVArrayOfCompareResults += $page:CSVCompareResultsPSOValues
}
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: The attribute values for the uploaded list of users has been processed." -Force
if (($CSVArrayOfCompareResults | Sort-Object userPrincipalName | Select-Object * -Unique).count -gt 0) {
$CSVArrayOfCompareResults | Select-Object employeeID, userPrincipalName, title, department, physicalDeliveryOfficeName, telephoneNumber, mobile, facsimileTelephoneNumber, streetAddress, city, st, postalCode, manager, accountExpirationDate, extensionAttribute5, extensionAttribute6, extensionAttribute7, extensionAttribute8, extensionAttribute15 | Export-Csv -Path $page:CSVCompareResultsPathandNameSuccess -Append -NoClobber -NoTypeInformation
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: The attribute values of the submitted users where logged before being updated in file: $session:CSVPreComparisonPathandName" -Force
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: The attribute values of the submitted users where logged after being updated in file: $session:CSVPostComparisonPathandName" -Force
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: The results from comparing the attribute values before and after import are available in file: $page:CSVCompareResultsPathandNameSuccess" -Force
}
else {
Add-Content -Path $session:LogfileExportPathandName -Value "INFO: After comparing the submitted users attribute values, NO changes were detected. A place holder file was created and is located in the log folder: $page:CSVCompareResultsPath" -Force
Add-Content -Path $page:CSVCompareResultsPathandNameSuccess -Value "This file was created as a placeholder. No differences where detected." -Force
}
TRUNCATED
}
New-UDButton -Id 'UDBTNImportFinished' -OnClick {
$session:ADPUserCSVData = $null
$page:ADPCSVUploadBodyRawData = $null
$page:ADPUploadFrmData = $null
$page:ADPUploadFrmFPathPlusFName = $null
$page:ADPUploadFrmFileName = $null
$page:ADPUploadPathValidation = $null
$page:ADPUploadFileValidation = $null
Invoke-UDRedirect -Url '/ImportADPCSVtoAD'
Hide-UDModal
} -Text 'FINISH' -Disabled:$True
} -FullScreen -Persistent
}