powershell - 起始位转移与paster兼容吗

标签 powershell pester

当我在脚本中运行start-bitstransfer时,我试图将事情应用到...上,这似乎不起作用...
我只是尝试下载一些随机的http页面(同时准备做一些tropico 5;)...到杵测试驱动器,但是这不起作用...
.net的东西不适用于paster或类似工具吗?

set-content "testdrive:\bla.txt" -value  "bla"
Start-BitsTransfer -source "http://www.tropicostrategy.com/p/blog-page.html" -destination 'testdrive:\' -Description "Downloading test"
Get-ChildItem 'TestDrive:\' | out-file c:\temp\b.txt

输出:
Describing get-wallhavens
  [-] downloads a file 591ms
    ArgumentException: Value does not fall within the expected range.
    ArgumentException: An incorrect value is specified in the Source parameter or in the Destination parameter. Verify that the directory and file names in the Source and Destination parameters are correct.
    at <ScriptBlock>, D:\stack\Projects\Personal\wallchange\download-wallpaper.Tests.ps1: line 7

最佳答案

The documentation on GitHub指示您需要使用一个变量来保存临时存储的实际位置:

Working with .NET Objects

When working directly with .NET objects, it's not possible to use the convenient TestDrive:\ PSDrive. Instead you need to use the $TestDrive variable which holds the actual path in a format that .NET understands. For example instead of using TestDrive:\somefile.txt use $TestDrive\somefile.txt instead.

关于powershell - 起始位转移与paster兼容吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51342309/

相关文章:

shell - Shell和PowerShell中的IPV6地址缩短

powershell - 有没有办法模拟美元?返回使用佩斯特?

powershell - 如何使用 Pester 模拟 $host.ui.PromptForChoice

powershell - 我如何通过 Powershell Pester 测试 ThrowTerminatingError

powershell - Pester 示例脚本在 Windows 10 上获取 "-Be is not a valid Should operator",在 Ubuntu 上运行良好

unit-testing - 模拟命令并根据调用模拟的次数获得不同的结果

c# - 如何在 C# 中解密通过 PowerShell 加密的字符串

arrays - powershell Get-ChildItem 结果在数组中

windows - 如何从命令行使用 LibreOffice 将 .doc 文件转换为 .txt?

azure - 运行带参数的 Set-AzVMRunCommand 命令会在目标上生成奇怪的失败文件