附加到 CSV 文件错误
Append to CSV file error
我正在尝试将新创建的用户帐户信息通过管道传输到 csv 文件中,我想存储随机密码、显示名称和他们的电子邮件地址,如 select 语句所示,我在哪里出错了?!
我的代码:
$newUserData = New-MsolUser -UserPrincipalName xxxx@xx.com -DisplayName xxxxx xxx -FirstName xxx -LastName xxxx
$newUserData | select password, displayname, userprincipalname | Export-Csv -Append -Force -Path "PATH TO FILE"
我的错误:
Export-Csv : Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run
the operation again.
At line:1 char:66
+ ... cipalname | Export-Csv -Append -Force -Path "PATH TO FILE" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Export-Csv], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.ExportCsvCommand
$newUserData 输出
> $newUserData
Password UserPrincipalName DisplayName isLicensed
-------- ----------------- ----------- ----------
xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx False
听起来发送到 export-csv 的对象或参数本身存在问题。试试这个:
New-Item -ItemType Directory -Path C:\Temp
$newUserData = New-MsolUser -UserPrincipalName User@example.com -DisplayName User -FirstName User -LastName Test
$newUserData | Select-Object -ExcludeProperty 'isLicensed' | Export-Csv -Path C:\Temp\UserDat.csv -Append -Force
我正在尝试将新创建的用户帐户信息通过管道传输到 csv 文件中,我想存储随机密码、显示名称和他们的电子邮件地址,如 select 语句所示,我在哪里出错了?!
我的代码:
$newUserData = New-MsolUser -UserPrincipalName xxxx@xx.com -DisplayName xxxxx xxx -FirstName xxx -LastName xxxx
$newUserData | select password, displayname, userprincipalname | Export-Csv -Append -Force -Path "PATH TO FILE"
我的错误:
Export-Csv : Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run
the operation again.
At line:1 char:66
+ ... cipalname | Export-Csv -Append -Force -Path "PATH TO FILE" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Export-Csv], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.ExportCsvCommand
$newUserData 输出
> $newUserData
Password UserPrincipalName DisplayName isLicensed
-------- ----------------- ----------- ----------
xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx False
听起来发送到 export-csv 的对象或参数本身存在问题。试试这个:
New-Item -ItemType Directory -Path C:\Temp
$newUserData = New-MsolUser -UserPrincipalName User@example.com -DisplayName User -FirstName User -LastName Test
$newUserData | Select-Object -ExcludeProperty 'isLicensed' | Export-Csv -Path C:\Temp\UserDat.csv -Append -Force