VMware Cloud Community
rogermccarrick
Contributor
Contributor

Adding VMFS LUN with Powershell CLI.

I have a DR SAN that has a few LUNs that are replicated with snapmirror from a prod SAN.

The LUN contains VMs.

The idea is to break the snapmirrors, mount the LUNs to the DR Virtual Center and inventory the VMs.

Here's a few things I did.

In the virtual center I manually added storage: select ESX host > choose Disk/LUN > Select the LUN > choose keep signature > and the LUN mounts as a VMFS datastore.

Then when I try to do the same thing on the next ESX host (there are 30 in the cluster), I get "Cannot change the configuration of the host"

I found an article that says "use new signature". So I removed the data store and added it again and it added to all the hosts as soon as I added it to the first. In other words I did not have to go through all 30 hosts. Great! .. But it named the datastore snap123_mydatastore. That's some random numbers after the word 'snap'. I just renamed that to mydatasore and it renamed it on all hosts. This is also great!

However I have a few luns and I want to do this with a powershell script because this has to be done frequently to test DR.

So I see that I can add a data store in powercli with:

New-Datastore -vmhost hostname -Vmfs -Name STORE_NAME -path (canonical name)

Looks like the canonical name can be found under identifier in the Storage Adapters view > iSCSI Software Adapter

So I ran the command

New-Datastore -vmhost esx10 -Vmfs -Name ESX_VMFS1A -path naa.60a9800050334b42636f57644e637965

and yes! this mounted the LUN to all hosts!

But it formated or deleted everything that was on it. Same for my second lun.

is there a switch that I can add to this command that imitates the manual process where you choose "New signature and keep all data on the lun" ?

thanks

0 Kudos
0 Replies