Public/Start-ComputerDataSanitization.ps1
Function Start-ComputerDataSanitization { <# .SYNOPSIS Accepts an filepath to a CSV or XLSX file containing AD Computer data and outputs a csv file to the same folder with " - Sanitized" appended to mark it as cleaned This function uses multiple other functions from this module .PARAMETER FilePath The path to the csv or excel file containing Computer object data you want to sanitize .OUTPUTS Outputs a file at the specified location with the sanitized data .EXAMPLE Start-ComputerDataSanitization "C:\Users\luke.hagar\Downloads\Computer Details.xlsx" -Verbose #> [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-ADComputerList $AllData Write-Verbose "Outputting results" Write-Verbose "$($OutputPath)" $Results | Export-CSV $OutputPath -NoTypeInformation } else { Write-Warning "Issues Importing Data" } } |