Original Message:
Sent: 11/25/2025 1:44:00 PM
From: Charlie Silverman
Subject: RE: Renaming files on a datastore
As it turns out, I did actually already find information about how to do this but I had misinterpreted something so it didn't work for me before.
There is a method for accessing a datastore via PowerCLI as a regular drive so you can use any of the methods that you would usually use (Remove-Item, Rename-Item, etc.). This is done using a PSDrive,
Sample code for this would be:
Connect-ViServer vcenter.mydomain.com
$datastore = Get-Datastore mydatastore
New-PSDrive -Location $datastore -Name myds -PSProvider VimDatastore -Root '\'
At this point, you can access the datastore as any other drive at myds:\, so to rename a file on the datastore, you could do something like:
Rename-Item -Path myds:\ISOs\myimage.iso -NewName mynewimage.iso
-------------------------------------------
Original Message:
Sent: Nov 24, 2025 02:13 AM
From: Charlie Silverman
Subject: Renaming files on a datastore
Is there a way to programmatically rename a file on a datastore with PowerCLI? I know that I can copy files to and from using Copy-DatastoreItem, and I know that I could just copy down, rename it locally, then copy it back up, but that is far too time consuming.
Short of opening an SSH session to a host, is there another way to do this?
If people are asking for a use case, let's just say that I need to rename an .iso file that is there for reasons.
-------------------------------------------