VMware Cloud Community
piotrlotr1
Contributor
Contributor
Jump to solution

Copy-DatastoreItem and it's Force SwitchParameter doesn't seem to be working?

Hi,

Just tried few combinations of Copy-DatastoreItem cmdlet and I don't see any difference between using it with our without -Force SwitchParameter. File still gets uploaded onto datastore. No warning, no error, nothing while uploading the same file with same name.

 

From VMware Dev Docu reg. -Force:

"Indicates whether to overwrite all items with the same name at the provided destination."

 

Anyone keen to test on his side?

 

Tested on PS/pCLI version:

 

PS C:\Users\piotrlotr1> $psversionTable

Name                           Value
----                           -----
PSVersion                      7.2.8
PSEdition                      Core
GitCommitId                    7.2.8
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

 

... and ...

 

PS C:\Users\piotrlotr1> Get-Module *VMware* | select Version, Name

Version         Name
-------         ----
7.0.2.17839075  VMware.Vim
12.3.0.17839331 VMware.VimAutomation.Cis.Core
12.3.0.17838947 VMware.VimAutomation.Common
12.3.0.17839688 VMware.VimAutomation.Core
12.2.0.17531155 VMware.VimAutomation.Sdk

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I can confirm, the Force switch has no impact.
The file is always overwritten.

This looks to be a PowerCLI bug since the underlying API seems to work as intended.

$src='[DS1] Folder/file.dat'
$dst = '[DS2] Folder/file.dat'

$dcName = 'MyDC'
$dc = Get-Datacenter -Name $dcName
$force = $true   # set to $false does not overwrite

$fileMgr = Get-View FileManager
$fileMgr.CopyDatastoreFile($src,$dc.Id,$dst,$dc.Id,$force)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

I can confirm, the Force switch has no impact.
The file is always overwritten.

This looks to be a PowerCLI bug since the underlying API seems to work as intended.

$src='[DS1] Folder/file.dat'
$dst = '[DS2] Folder/file.dat'

$dcName = 'MyDC'
$dc = Get-Datacenter -Name $dcName
$force = $true   # set to $false does not overwrite

$fileMgr = Get-View FileManager
$fileMgr.CopyDatastoreFile($src,$dc.Id,$dst,$dc.Id,$force)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

piotrlotr1
Contributor
Contributor
Jump to solution

What do we with this? How and should we let VMware know there is a problem with that switch?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can open an SR.

If GSS tells you that you need a Developer Support contract for opening PowerCLI-related SRs, they are wrong.
You can also pass this to your TSA, who can probably contact the PowerCLI Team directly.

I will in any case bring this thread to the attention of the PowerCLI Team.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference