Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Import-CSV is blank and empty

$
0
0

My CSV looks like this

Name,Address
Dave,Dave@dave.com
Dave,Dave2@dave.com
Dave,Dave3@dave.com

I've stored this on my C:drive, called it 'alias.csv' and ran this command:

PS C:\>Import-CSV "alias.csv" | ForEach {Set-Mailbox $_.Name -EmailAddresses @{add=$_.Address}}

It goes straight to a flashing cursor.

But then I addresses are not listing.

I can add them individually with no problem at all.

Set-Mailbox dave -EmailAddresses @{add="dvealias@dave.com"}

This works fine so I'm thinking there must be something wrong with the CSV.  I try this command:

Get-ChildItem 'alias.csv' | ForEach {

    $check = Import-Csv $_

    If ($check) { Write-Host "$($_.Name) contains data" }

    Else { Write-Host "$($_.Name) does not contain data" }

}

And it comes back with

does not contain data

Every time....it's not reading the CSV at all.  But If I do this:

PS C:\> Get-Content alias.csv

It lists the contents of the CSV!!

Why is import not working? 

It worked yesterday LOL

Thanks!

* Just tried on another PC and it's working.  Must be something to do with powershell.

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>