0

我不确定为什么这个问题已经关闭并得到了分数,但如果没有人能回答它,那么有人可以指出我可以得到答案的方向吗?谢谢。这里又是:

该文件不会用Get-ChildItem或复制过来Copy-Item。这是未运行脚本的实际 powershell 窗口的输出:

PS C:\> Open-Device 10.42.233.237
Connecting to device '10.42.233.237' ...


Device Name : 10.42.233.237
Device IP   : 10.42.233.237
Device Host :

Run 'Get-Variable Device*' to see variables set for the connected session.


DEVICE C:\
PS C:\> Get-ChildItem -Path "V:\WP\QM\Audio\Decode\Automated" -Filter *.3g2 | Copy-Item -Destination C:\test\MinTE
DEVICE C:\
PS C:\> putd -Path "V:\WP\QM\Audio\Decode\Automated" -Filter "*.3g2" -Destination "C:\test\MinTE"
Put-Device : A parameter cannot be found that matches parameter name 'Path'.
At line:1 char:6
+ putd -Path "V:\WP\QM\Audio\Decode\Automated" -Filter "*.3g2" -Destination "C:\te ...
+      ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Put-Device], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Texus.Shells.PowerShell.PutFileDeviceCmdlet

DEVICE C:\
PS C:\>

putd 是 Put-Device 的缩写。Get-ChildItem 和 Copy-Item 在连接到设备时不起作用。它们无法识别为 cmdlet 函数。这是获取想法的完整脚本:

param(
$SourcePath, $DestinationPath
)

# Display something just as a sanity check
Write-Output "Starting Setup";

# Waits to gather input
Start-Sleep -m 1000

# Connect to device
Open-Device $env:IP_Address | out-null

# Waits to establish a connection to the device
Start-Sleep -m 2000

# Copy a files to the device
Write-Output "Copying testcases and support files..."
putd $env:source\*.mp4 C:\test\MinTE | out-null
putd $env:source\*.mp3 C:\test\MinTE | out-null
putd $env:source\*.wma C:\test\MinTE | out-null
putd $env:source\*.m4a C:\test\MinTE | out-null
putd $env:source\*.amr C:\test\MinTE | out-null
putd $env:source\*.wav C:\test\MinTE | out-null
putd $env:source\*.3g2 C:\test\MinTE | out-null
putd $env:source\*.3gp C:\test\MinTE | out-null
putd $env:source\*.xml C:\test\MinTE | out-null


# Closes Connection to device
Close-Device

# Allows space for easy reading for the user
Write-Output " "
Write-Output " "
Write-Output " "
Write-Output " "

# Tells the user the script ran successfully
Write-Output "... Setup Successful (NO REBOOT REQUIRED)"

exit;

执行批处理文件命令时,使用带有用户输入的两个变量的批处理文件调用此脚本。它已经过测试并适用于除“.3gp”和“.3g2”之外的所有其他文件类型。我注意到在 .ps1 脚本(使用 notpad++)的任何位置添加“3”时,颜色变为橙色,而在 .ps1 脚本(使用 notpad++)的任何位置添加“gp”时,颜色变为浅蓝色。这告诉我这两个可能是开关,但我不确定是什么。

此外,如果需要重现错误,这里是用于执行此脚本的批处理文件:

@echo off
::Conditions leading to errors if the batch script is not executed correctly
if "%1"=="" goto error1
if "%2"=="" goto error2

::Allows user to set the "Source Path" to copy the testcase files from
set source=%1
::Allows user to set the "Destination Path" to copy the testcase files from
set IP_Address=%2

:: Does a health check to ensure source path is valid
IF NOT EXIST "%source%" goto error3
:: Does a health check to ensure Device IP Address is valid
ping -n 1 -w 100 %IP_Address% 1>nul
if "%errorlevel%"=="1" goto error4

::Tells the user what the "Source" and "Destination" Paths are
echo Source Path = %1
echo Destination Path = %2
echo.
powershell.exe -File "BVT_AudioDecode_Automated.ps1" %1 %2 -NoProfile -NoExit


goto end
:error1
echo.
echo Error Syntax: BVT_AudioDecode_Setup.bat "Source_Path\AudioDecode_Testcase_Folder" "Device IP Address"
echo.
echo For example: BVT_AudioDecode_Setup.bat V:\WP\BVT\Audio\Decode 10.42.233.237
echo              -or-
echo              BVT_AudioDecode_Setup.bat C:\WP\BVT\Audio\Decode 10.42.233.237
echo.
echo.
goto end
:error2
echo.
echo Error Syntax: BVT_AudioDecode_Setup.bat "Source_Path\AudioDecode_Testcase_Folder"     "Device IP Address"
echo.
echo For example: BVT_AudioDecode_Setup.bat V:\WP\BVT\Audio\Decode 10.42.233.237
echo              -or-
echo              BVT_AudioDecode_Setup.bat C:\WP\BVT\Audio\Decode 10.42.233.237
echo.
echo.
goto end
:error3
echo.
echo Error: Invalid Path
echo %source%
goto end
:error4
echo.
echo Error: Invalid IP Address
echo %IP_Address%
goto end
:end

当我Open-Device运行. 如果没有人认出这个列表,那么也许我来错地方了:Putdget-command

Cmdlet          Add-FederatedDeviceHost                            TexusCmdlets
Cmdlet          Add-FederatedEnvironment                           TexusCmdlets
Cmdlet          Add-VirtualMachine                                 TexusCmdlets
Cmdlet          CD-Device                                          TexusCmdlets
Cmdlet          Close-Device                                       TexusCmdlets
Cmdlet          Cmd-Device                                         TexusCmdlets
Cmdlet          Copy-Device                                        TexusCmdlets
Cmdlet          Create-FederatedVirtualDeviceHost                  TexusCmdlets
Cmdlet          Create-Federation                                  TexusCmdlets
Cmdlet          Debug-Device                                       TexusCmdlets
Cmdlet          Del-Device                                         TexusCmdlets
Cmdlet          Deploy-Device                                      TexusCmdlets
Cmdlet          Dir-Device                                         TexusCmdlets
Cmdlet          Exec-Device                                        TexusCmdlets
Cmdlet          Filter-Result                                      TexusCmdlets
Cmdlet          Get-ChildPrimitive                                 TexusCmdlets
Cmdlet          Get-Device                                         TexusCmdlets
Cmdlet          Get-ResultSummary                                  TexusCmdlets
Cmdlet          Get-SuiteName                                      TexusCmdlets
Cmdlet          Get-TaskOutputPath                                 TexusCmdlets
Cmdlet          Get-VirtualMachineNames                            TexusCmdlets
Cmdlet          Kill-Device                                        TexusCmdlets
Cmdlet          Merge-Reports                                      TexusCmdlets
Cmdlet          MkDir-Device                                       TexusCmdlets
Cmdlet          Mount-VirtualDisk                                  TexusCmdlets
Cmdlet          Move-Device                                        TexusCmdlets
Cmdlet          Open-Device                                        TexusCmdlets
Cmdlet          Put-Device                                         TexusCmdlets
Cmdlet          Reg-Device                                         TexusCmdlets
Cmdlet          Remove-FederatedDeviceHost                         TexusCmdlets
Cmdlet          Remove-VirtualMachine                              TexusCmdlets
Cmdlet          RmDir-Device                                       TexusCmdlets
Cmdlet          Set-VirtualMachine                                 TexusCmdlets
Cmdlet          Show-Result                                        TexusCmdlets
Cmdlet          Start-VirtualMachine                               TexusCmdlets
Cmdlet          Stop-VirtualMachine                                TexusCmdlets
Cmdlet          Test-Device                                        TexusCmdlets
Cmdlet          TList-Device                                       TexusCmdlets
Cmdlet          Type-Device                                        TexusCmdlets
Cmdlet          Unmount-VirtualDisk                                TexusCmdlets
Cmdlet          Validate-FederatedDeviceHost                       TexusCmdlets
4

1 回答 1

1

我终于找到了答案!

PS U:\> get-help put-device -full

Do you want to run Update-Help?
The Update-Help cmdlet downloads the newest Help files for Windows PowerShell modules and installs them on your
computer. For more details, see the help topic at http://go.microsoft.com/fwlink ?LinkId=210614.
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

NAME
    Put-Device

SYNOPSIS
    Copies one or more files from the host machine to the connected device.

SYNTAX
    Put-Device [-Source] [<string>] [[-Destination] [<string>]] [<CommonParameters>]


DESCRIPTION
    The Put-Device cmdlet copies one or more files from the host machine to the connected device.
    Absolute paths are used as-is and relative paths are treated relative to the
    current working directory, either on the device or the host.


PARAMETERS
    -Source [<string>]
        The path of the source file(s) on the host ('*' and '?' wildcards are supported).

        Required?                    true
        Position?                    0
        Default value
        Accept pipeline input?
        Accept wildcard characters?

    -Destination [<string>]
        The path of the destination file or directory on the device.
        If omitted, the current working directory on the device will be used.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?
        Accept wildcard characters?

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, see
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS


RELATED LINKS

获得此信息后,这是解决问题的正确命令:

putd -Source "$env:source\*.3gp" -Destination "C:\test\MinTE" | out-null

我会留下这个,以防有人可以从中吸取教训。

于 2013-03-13T18:09:35.877 回答