Copy-VMFile
Copy-VMFile
Copies a file to a virtual machine.
语法
Parameter Set: Name
Copy-VMFile [-Name] <String[]> [-SourcePath] <String> [-DestinationPath] <String> -FileSource <CopyFileSourceType> [-AsJob] [-ComputerName <String[]> ] [-CreateFullPath] [-Force] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: VMObject
Copy-VMFile [-VM] <VirtualMachine[]> [-SourcePath] <String> [-DestinationPath] <String> -FileSource <CopyFileSourceType> [-AsJob] [-CreateFullPath] [-Force] [-Confirm] [-WhatIf] [ <CommonParameters>]
详细说明
The Copy-VMFile cmdlet copies a file to a virtual machine.
参数
-AsJob
别名 |
无 |
是否为必需? |
false |
位置? |
named |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-ComputerName<String[]>
Specifies an array of Hyper-V hosts. The cmdlet copies the file to the hosts you specify.
别名 |
无 |
是否为必需? |
false |
位置? |
named |
默认值 |
. |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-CreateFullPath
Indicates that when the cmdlet copies a file, it creates folders if the folder does not already exist.
别名 |
无 |
是否为必需? |
false |
位置? |
named |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-DestinationPath<String>
Specifies a path. The cmdlet copies the file to the destination path.
别名 |
无 |
是否为必需? |
true |
位置? |
3 |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-FileSource<CopyFileSourceType>
Specifies the type of a file source.
别名 |
无 |
是否为必需? |
true |
位置? |
named |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Force
在不请求用户确认的情况下,强制该命令运行。
别名 |
无 |
是否为必需? |
false |
位置? |
named |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Name<String[]>
Specifies an array of virtual machine objects by name. The cmdlet copies files to the virtual machines you specify.
别名 |
VMName |
是否为必需? |
true |
位置? |
1 |
默认值 |
无 |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-SourcePath<String>
Specifies a path. The cmdlet copies the file from the source path.
别名 |
无 |
是否为必需? |
true |
位置? |
2 |
默认值 |
无 |
是否接受管道输入? |
True (ByValue) |
是否接受通配符? |
false |
-VM<VirtualMachine[]>
Specifies an array of virtual machine objects. The cmdlet copies files to the virtual machines you specify. To obtain a virtual machine object, use the Get-VM cmdlet.
别名 |
无 |
是否为必需? |
true |
位置? |
1 |
默认值 |
无 |
是否接受管道输入? |
True (ByValue) |
是否接受通配符? |
false |
-Confirm
运行 cmdlet 之前提示你进行确认。
是否为必需? |
false |
位置? |
named |
默认值 |
false |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-WhatIf
显示如果运行 cmdlet 则会发生什么情况。cmdlet 未运行。
是否为必需? |
false |
位置? |
named |
默认值 |
false |
是否接受管道输入? |
false |
是否接受通配符? |
false |
<CommonParameters>
此 cmdlet 支持通用参数:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。有关详细信息,请参阅 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
输入
输入类型是指可通过管道传送给 cmdlet 的对象的类型。
输出
输出类型是 cmdlet 所发出对象的类型。
示例
Example 1
This example copies the file “test.txt” from the host operating system into the guest operating system of the virtual machine “Test VM”. It will create the directory “C:\Temp” inside the guest operating system if it does not exist already.
PS C:\> Copy-VMFile "Test VM" -SourcePath "D:\Test.txt" -DestinationPath "C:\Temp\Test.txt" -CreateFullPath -FileSource Host