0

We have a PowerShell script which creates an user in Microsoft Exchange and Active Directory.

We get the user's data by a preformated txt which serves as sort of CSV with:

$data = import-csv signup.txt

But the problem is that, as we are from Spain, sometimes it arises the character ñ which isn't picked up by the script and generates a bad username and bad data. So, we put it with N and then enter in Exchange and we change it from there again.

How can I fix that problem?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Antonio Laguna
  • 8,973
  • 7
  • 36
  • 72
  • Experiment with `$csvdata = get-content -encoding windows-1250 signup.txt` and the like. – user1686 Oct 20 '11 at 11:49
  • Get-Content : Cannot bind parameter 'Encoding'. Cannot convert value "windows-1 250" to type "Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding" d ue to invalid enumeration values. This doesn't work – Antonio Laguna Oct 20 '11 at 12:08
  • Get-Content allows those encodings "Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, Ascii" – Tom Oct 26 '11 at 11:08

1 Answers1

2

I recommend converting the file to UTF-8. Because the import-csv cmdlet works with it.

I usually create an empty file in notepad++ with UTF-8 encoding and copy the text from the other file. Or as stated here

Get-Content signup.txt -Encoding Ascii | Out-File signup_utf8.txt -Encoding UTF8
Import-Csv signup_utf8.txt
Community
  • 1
  • 1
Tom
  • 1,611
  • 1
  • 13
  • 16