小编Scr*_*ese的帖子

PowerShell 将对象附加到变量列表

对 PowerShell 相当陌生,想要了解如何将对象附加到变量列表。以下是错误消息:

Method invocation failed because [System.IO.FileInfo] does not contain a method named 'op_Addition'.
At C:\Users\Username\Desktop\Sandbox\New folder\BoxProjectFiles.ps1:117 char:4
+             $MechDWGFile += $file
+             ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
Run Code Online (Sandbox Code Playgroud)

和代码:

LogWrite "`n-------------Mechanical Drawing(s)------------"
foreach ($file in $MechDWGList)
{
    # Where the file name contains one of these filters
    foreach($filter in $MechDWGFilterList)
    {
        if($file.Name -like $filter)
        {
            $MechDWGFile += $file # this is where the error is happening, so I know it is probably …
Run Code Online (Sandbox Code Playgroud)

variables powershell append

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

append ×1

powershell ×1

variables ×1