What is the meaning of Powershell's Copy-Item's -container argument?

后端 未结 2 773
走了就别回头了
走了就别回头了 2020-12-05 22:41

I am writing a script for MS PowerShell. This script uses the Copy-Item command. One of the optional arguments to this command is \"-container\".

2条回答
  •  一向
    一向 (楼主)
    2020-12-05 23:22

    The container the documentation is talking about is the folder structure. If you are doing a recursive copy and want to preserve the folder structure, you would use the -container switch. (Note: by default the -container switch is set to true, so you really would not need to specify it. If you wanted to turn it off you could use -container: $false.)

    There is a catch to this... if you do a directory listing and pipe it to Copy-Item, it will not preserve the folder structure. If you want to preserve the folder structure, you have to specify the -path property and the -recurse switch.

提交回复
热议问题