Public/Set-CompanyDetails.ps1
function Set-CompanyDetails { [CmdletBinding(PositionalBinding = $false)] param ( [Parameter(Mandatory = $true)][object[]]$PersonDataInput, [Parameter(Mandatory = $true)][hashtable]$OuMap, [Parameter(Mandatory = $true)][string]$CompanyName, [Parameter(Mandatory = $true)][string]$DefaultDomain, [Parameter(Mandatory = $true)][string[]]$DomainProxyList ) try { $noOffice365TitleFile = "./TitleFiles/noO365.txt" $noOffice365TitleList = Get-Content $noOffice365TitleFile -ErrorAction: Stop | ? { $_.Length -gt 3 } $fieldUserTitleFile = "./TitleFiles/fieldUsers.txt" $fieldUserTitleList = Get-Content $fieldUserTitleFile -ErrorAction: Stop | ? { $_.Length -gt 3 } $itUserTitleFile = "./TitleFiles/itUsers.txt" $itUserTitleList = Get-Content $itUserTitleFile -ErrorAction: Stop | ? { $_.Length -gt 3 } foreach ($emp in $PersonDataInput) { $emp.companyName = $CompanyName $emp.defaultDomain = $DefaultDomain $emp.domainProxyList = $DomainProxyList if ($noOffice365TitleList -contains $emp.positionTitle) { $emp.userType = 'noOffice365' $emp.defaultOu = $OuMap.noOffice365 } elseif ($fieldUserTitleList -contains $emp.positionTitle) { $emp.userType = 'fieldUser' $emp.defaultOu = $OuMap.fieldUser } elseif ($itUserTitleList -contains $emp.positionTitle) { $emp.userType = 'itUser' $emp.defaultOu = $OuMap.itUser } elseif ($emp.positionTitle -match '^VP|^Chief|^Executive') { $emp.userType = 'execUser' $emp.defaultOu = $OuMap.execUser } else { $emp.userType = 'normalUser' $emp.defaultOu = $OuMap.default } } return $PersonDataInput } catch { Write-Log -LogText "Error importing title file. Aborting script." -LogType: error -ErrorObject $_ return $null } } |