Public/Start-DataSanitization.ps1

Function Start-DataSanitization {
    [CmdletBinding()]
    param (
        $FilePath
    )
    $Path = Get-ChildItem $FilePath
    $OutputPath = "$($Path.Directory)" + "\" + "$($Path.BaseName)" + " - Sanitized.csv"
    If ($FilePath -like "*.csv") {
        Write-Verbose "CSV Provided"
        $Data = Import-CSV $FilePath
    }
    If ($FilePath -like "*.xlsx") {
        Write-Verbose "XLSX Provided"
        Try { $Data = Import-Excel $FilePath }
        Catch { Install-Dependencies }
        Try { $Data = Import-Excel $FilePath }
        Catch { Throw $_ }
    }
    if ($null -ne $Data) {
        Write-Verbose "Getting Properties"
        $Properties = Get-Properties $Data
        Write-Verbose "Gathering Array values"
        $AllData = Get-AllArrayData -Array $Data -Properties $Properties
        Write-Verbose "Querying AD for Data"
        $Results = Get-ADUserList $AllData
        Write-Verbose "Outputting results"
        Write-Verbose "$($OutputPath)"
        $Results | Export-CSV $OutputPath -NoTypeInformation
    }
    else {
        Write-Warning "Issues Importing Data"
    }
}