- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RDM Disks -> Existing Disk - Using New-HardDisk Errors
I am writing a powershell/powercli script to automate adding RDM disks to two VM's in a two node Windows Failover Cluster for SQL.
The RDM disks are presented from a physical storage unit and using their naa.id's I can successfully add them to my first VM without issue using the New-HardDisk module like shown below (thanks lucd for earlier help):
$DataStore = "DataStore_Name_RDM"
$VM1 = Get-VM -Name "VM1"
$VM2 = Get-VM -Name "VM2"
----------------
VMware.PowerCLI 13.1.0 build 21624340
---------------
Component Versions
---------------
VMware Common PowerCLI Component 13.0 build 20797081
VMware Cis Core PowerCLI Component PowerCLI Component 13.0 build 20797636
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 13.0 build 20797821
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Select-Object cmdlet doesn't return a single String, but an object.
The DiskPath expects a String.
Try with
$DiskPath = ((Get-VM -Name $Server1 | Get-HardDisk | Where-Object {$_.Filename -Match "_RDM"}).FileName)[1]
Note: assuming that the 2nd returned String , with [1], is the correct HD might be risky.
Better is to match part of the value in the FileName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply.
I tried it with:
$DiskPath = ((Get-VM -Name $Server1 | Get-HardDisk | Where-Object {$_.Filename -Match "_RDM"}).FileName)[1]No luck, same error still unfortunately.
For now using [1] is ok but in my full code for the automation I have an index that increments with every loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you check what you have in $DiskPath and the type?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I did, sorry I should have put the results.
Type
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
And the output was as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And how did you do the New-HardDisk?
Because that should now be
New-HardDisk -VM $VM2 -DiskPath $DiskPath | New-ScsiController -Type ParaVirtual -BusSharingMode Physical
No FilePath property
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yep the New-HardDisk command was exactly as you pasted, without the .FileName extension:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then I'm out of ideas I'm afraid.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sad times :(.
I will keep looking and feedback here if I find anything!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With a bit more investigation I have found that this is nothing to do with the code. It looks to be down to some specific datastores in our vCenter as I have my script working on a different datastore, using the methods discussed here + some.
No idea what the cause is on the datastore, but we are looking further.
If you have any suggestions, please fire away!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
So far I've now found this difference.
When running:
My files do not show in the results, but if I browse to the datastore in the GUI, the files show.
They show their 'type' is of 'File' as you can see below
I am adding the disks to each DS in the exact same way... Any thoughts on this one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could try to unregister/register that VM, and check if that changes the type of the files.
Do all VMs on that datastore show the VMDK as "file"?
I suggest opening an SR.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I normally create new scsi controller first on second node with flat disk, then get scsi name
Then, get disk naa id from node 1 and export result to csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the suggestion JieX, I already have the naa.id for the disk and the issue isn't creating the SCSI controller.
Considering the code works 100% on Datastores with a version of 6.81, its got to be something related to the versioning and the file type.
We will be raising a SR soon once I get relevant access from the company I work for.