I've mixed data(some row are empty) like this in my csv column called "Exchange Mailboxes".
Exchange Mailboxes
Include:[john.doe@outlook.com]
Include:[david.smith@outlook.com]
Include:[kevin.love@outlook.com]
I'm try to check if the row is empty first. If it's empty then just assigned empty string for those row. If a particular csv row is not empty then get their Name and Id using EXOMailbox.
Another word will be, how do I skip an empty rows?
I tried it like this but some reason it's not working.
$importFile = Import-Csv -Path "C:\AuditLogSearch\Dis\Modified-Audit-Log-Records.csv"
foreach ($csvFile in $importFile){
if([string]::IsNullOrEmpty($csvFile.'Exchange Mailboxes')){
$userName = ""
$userId = ""
}else{
$exoMailbox = $csvFile.'Exchange Mailboxes'.Split([char[]]@('[', ']'))[1]
$exoUser = Get-EXOMailbox -Filter "PrimarySmtpAddress -eq '$exoMailbox'"
$userName = $exoUser.DisplayName
$userId = $exoUser.Identity
}
}