【发布时间】:2019-08-14 06:32:54
【问题描述】:
我有一个包含用户名 city 的 excel 文件。我正在尝试向同一个 excel 添加一个新列,假设该列是部门。我有不同的用户列表,它告诉我哪个用户属于哪个部门。我现在正在尝试更新我拥有的原始 excel 文件中的 Dept 列。我目前的代码如下
$test = import-csv .\test.csv | Select Name,City,Dept
if ($test.name = 'John'){
$test.Dept = 'HR'
}
它不起作用,得到这个错误
Exception setting "Name": "The property 'Name' cannot be found on this object. Verify that the property exists and can be set."
At line:2 char:1
+ $test.Name= 'John'
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
不确定我在哪里做错了,这是否是正确的方法。
【问题讨论】:
标签: excel powershell