我每天都需要修改CSV,以便我可以配置帐户。它需要简单的信息并创建新帐户。我可以处理用于在AD中创建帐户的PowerShell,它正在修改CSV。我需要创建一个用户名和一个带有附加文本的电子邮件地址。
输入将如下所示:
First,Last,School,Attribute,Description John,Smith,Elementary,A2F,teacher Joe,Johnson,High School,A2F,teacher Greg,Harris,Middle School,A2F,teacher
输出需要如下所示:
First,Last,School,Attribute,Description,Username,Email John,Smith,Elementary,A2F,teacher,JSmith.sfo,John.Smith.sfo@googledomain.org Joe,Johnson,High School,A2F,teacher,JJohnson.sfo,Joe.Johnson.sfo@googledomain.org Greg,Harris,Middle School,A2F,teacher,GHarris.sfo,Greg.Harris.sfo@googledomain.org
答案 0 :(得分:1)
将Select-Object
与所需的每个新列一起使用计算属性:
Import-Csv .\old.csv |
Select-Object *,@{Name='Username';Expression={'{0}{1}.sfo' -f $_.First[0],$_.Last}},@{Name='Email';Expression={'{0}.{1}.sfo@googledomain.org' -f $_.First,$_.Last}} |
Export-Csv .\new.csv -NoTypeInformation