相关疑难解决方法(0)

Powershell的Copy-Item的-container参数是什么意思?

我正在为MS PowerShell编写脚本.该脚本使用该Copy-Item命令.此命令的可选参数之一是" -container".该参数的文档声明指定此参数"在复制操作期间保留容器对象".

这一切都很好,因为在复制操作期间,我将是最后一个想要未预留容器对象的人.但严肃地说,这个论点有什么作用?特别是在我将磁盘目录树从一个地方复制到另一个地方的情况下,这对Copy-Item命令的行为有何不同?

powershell copy-item

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

使用黑名单(排除)和白名单(包括)的 Powershell 复制文件

我正在将一些 msbuild 脚本翻译为 powershell。

在 msbuild 中,我可以生成要(递归)复制到目标文件夹的文件的黑名单和/或白名单。

如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">

    <PropertyGroup>
        <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases  -->
        <WorkingCheckout>.</WorkingCheckout>
        <WindowsSystem32Directory>c:\windows\System32</WindowsSystem32Directory>
        <ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder>
    </PropertyGroup>

    <Target Name="AllTargetsWrapped">

        <CallTarget Targets="CleanArtifactFolder" />
        <CallTarget Targets="CopyFilesToArtifactFolder" />
    </Target>

    <Target Name="CleanArtifactFolder">

        <RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/>
        <MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/>
        <Message Text="Cleaning done" />
    </Target>

    <Target Name="CopyFilesToArtifactFolder">

        <ItemGroup>
            <MyExcludeFiles Include="$(WindowsSystem32Directory)\**\EventViewer_EventDetails.xsl" />
        </ItemGroup>

        <ItemGroup>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xsl" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xslt" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.png" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.jpg" …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-5.0

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

标签 统计

powershell ×2

copy-item ×1

powershell-5.0 ×1