将文件扩展名作为参数传递给powershell脚本

时间:2018-03-03 12:50:20

标签: powershell windows-10

我正在使用此powershell命令来展平目录。 下面这行很好用:

    Get-ChildItem . -Recurse -Filter "*.mp3" |  Move-Item -destination ..\Duplicates\

但是当该行用作脚本时,我不确定如何将"*.mp3"传递给下面的脚本。     我收到InvalidArgument: error

FlattenDirectory.ps1 . "*.mp3" ..\Duplicates\
    # FlattenDirectory.ps1
    Param(
        [string]$From,
        [string]$Ext
        [string]$To
    )

1 个答案:

答案 0 :(得分:2)

,区块中缺少Param

Param(
    [string]$From,
    [string]$Ext, # here
    [string]$To
)
相关问题