PowerShell脚本获取UTF8?
我们有一个 PowerShell 脚本,可以在 Microsoft Exchange 和 Active Directory 中创建用户。
我们通过预格式化的 txt 获取用户数据,该 txt 充当 CSV 的形式:
$data = import-csv signup.txt
但问题是,由于我们来自西班牙,有时会出现字符 ñ
,该字符未被系统拾取脚本并生成错误的用户名和错误的数据。因此,我们将其与 N 一起输入,然后进入 Exchange,然后再次从那里更改它。
我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议将文件转换为 UTF-8。因为 import-csv cmdlet 可以使用它。
我通常在 notepad++ 中使用 UTF-8 编码创建一个空文件,然后从另一个文件复制文本。
或者如此处所述
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