tag:blogger.com,1999:blog-2269516327950490847.post2682002929975711619..comments2023-03-28T08:39:06.775-04:00Comments on vNugglets: Get VM Disks and RDMs via PowerCLIAC (@allen_crawford)http://www.blogger.com/profile/05360032132878174436noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-2269516327950490847.post-2383822799874301062021-02-03T20:21:49.504-05:002021-02-03T20:21:49.504-05:00Heyy, Anonymous-
Excellent, glad to hear it. And...Heyy, Anonymous-<br /><br />Excellent, glad to hear it. And, thanks for sharing the useful adds!<br /><br />CheersMattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-85591738448509052112021-01-30T14:46:28.993-05:002021-01-30T14:46:28.993-05:00This is a great function, I use for several years ...This is a great function, I use for several years now. <br />I added the above lines which allow to identify Multi-writer, persistence and eager zeroed disks. As I deal with virtual oracle RAC cluster it is very useful:<br />MultiWriter = $hdThisDisk.backing.sharing<br />IsEagerZeroed = $hdThisDisk.backing.eagerlyscrub<br />Persistence = $hdThisDisk.backing.DiskMode<br /><br />I hope it helps<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-17868465781498373312018-03-15T12:00:53.558-04:002018-03-15T12:00:53.558-04:00I would like to get the LUN ID of the Data store w...I would like to get the LUN ID of the Data store where the disks presented. Both VMDK and RDM disk LUN IDAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-84776531636037784642018-01-25T12:45:15.013-05:002018-01-25T12:45:15.013-05:00Hell, Unknown-
Thanks, glad the code is useful to...Hell, Unknown-<br /><br />Thanks, glad the code is useful to you.<br /><br />And, yes, there is. You could do so with a couple of updates:<br />insert a line after line 42 like:<br />DiskMode = $hdThisDisk.Backing.DiskMode<br /><br />and then, update current line 45 (which will be line 46 after you add the line above, of course) to be:<br />$arrPropertiesToSelect = "VMName,HardDiskName,ScsiId,DeviceDisplayName,SizeGB,ScsiCanonicalName,DiskMode".Split(",")<br /><br />Further info for supported functionality: The vNugglets.Utility PowerShell module supersedes this function now (available from the PowerShell Gallery), and the source is in the repo at https://github.com/vNugglets/vNuggletsPSMod. I have opened an enhancement request Issue there (https://github.com/vNugglets/vNuggletsPSMod/issues/1) for this property add to the return objects from the Get-VNVMDiskAndRDM function. Once that function/module are updated, you will be able to do something like:<br /><br />Get-VM myVM | Get-VNVMDiskAndRDM<br /><br />...and get all of the juicy disk info that you desire. Enjoy!MattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-15208323044813743462018-01-10T11:27:42.823-05:002018-01-10T11:27:42.823-05:00Thank you so much for this script! I have been loo...Thank you so much for this script! I have been looking for a script that exports both disk AND scsi info for a very long time. Is there a way to export the disk persistence info along with what this script already accomplishes? Thank you!Unknownhttps://www.blogger.com/profile/14142189800059818646noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-43445356312476436742017-10-27T05:29:33.190-04:002017-10-27T05:29:33.190-04:00Very interesting info !Perfect just what I was lo...Very interesting info !Perfect just what I was looking for! <a href="https://www.nayashopi.in/external-hard-disk" rel="nofollow"></a>Anonymoushttps://www.blogger.com/profile/02532878645325460863noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-36967163020665992602016-11-22T17:03:58.329-05:002016-11-22T17:03:58.329-05:00Great script!
Every time I try to use it on a VM w...Great script!<br />Every time I try to use it on a VM with an asterisk in its name it doesn't work.<br />For example: Get-VMDiskAndRDM -vmName_str *vm_name<br />Results in: <br />Get-View parsing "*vm_name" - Quantifier {x,y} following nothing.<br />At E:\PS\functions\get-vmdiskandRDM.ps1:22 char:33<br />+ ... orageInfo = Get-View -Viewtype VirtualMachine -Property Name, Config. ...<br />+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : NotSpecified: (:) [Get-View], VimException<br /> + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView<br /><br />Any tip?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-35844739513659709862016-07-14T16:20:42.431-04:002016-07-14T16:20:42.431-04:00Thanks for great script,
Is possible to get value...Thanks for great script,<br /><br />Is possible to get value DeviceDisplayName and ScsiCanonicalName for regular disk with VM?<br /><br />Regards,<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-70310333900823354172016-07-07T18:58:27.390-04:002016-07-07T18:58:27.390-04:00Thanks for the tidbit, EdThanks for the tidbit, EdMattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-43638335912348179662016-07-07T18:58:04.206-04:002016-07-07T18:58:04.206-04:00Hello, Anonymous-
Looks like you figured out the ...Hello, Anonymous-<br /><br />Looks like you figured out the part of, "after having defined the function in PowerShell session, _then_ invoke the function by name -- call Get-VMDiskAndRDM with parameters".<br /><br />As for those two properties having $null values: if you see after the code block in this post, there is a bit about, "The disks with no values for the DeviceDisplayName or ScsiCanonicalName properties are the "regular" virtual disks, and the others are RDMs".<br /><br />So, it sounds like the VM "myvirtualserver" only has regular virtual disks (no RDMs). Might that be the case?MattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-8397782090355333922016-06-16T11:48:58.298-04:002016-06-16T11:48:58.298-04:00The SCSI Bus number is stored in the controller...The SCSI Bus number is stored in the controller's device object. It is just luck that you can usually calculate it from the controller key.<br /><br /># before the disk loop<br />$devicehash = @{}<br />$viewVMForStorageInfo.Config.Hardware.Device | %{$devicehash[$_.Key] = $_}<br /><br />#inside the loop<br />$ScsiBus = $devicehash[$hdThisDisk.ControllerKey].BusNumber<br /><br /><br />I don't have a clean way yet to test for IDE drives.Anonymoushttps://www.blogger.com/profile/15208708439157773731noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-62865700058626056352016-05-20T17:23:48.625-04:002016-05-20T17:23:48.625-04:00Seems if i just put this as the last line in the f...Seems if i just put this as the last line in the function and run it in powershell it works.<br />Get-VMDiskAndRDM -vmName myvirtualserver -ShowVMDKDatastorePath | ft -a<br /><br />However not getting anything back for DeviceDisplayName or ScsiCannoicalName?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-91311441824038245482016-05-20T16:22:21.259-04:002016-05-20T16:22:21.259-04:00Sorry newbie here, when running this command with ...Sorry newbie here, when running this command with .\ in front (else it says it cannot find) nothing happens, runs very quick with no output, any idea what I'm doing wrong?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-68680037236027333022016-04-22T15:31:24.636-04:002016-04-22T15:31:24.636-04:00Hello, Anonymous-
Surre! We can stay off of the ...Hello, Anonymous-<br /><br />Surre! We can stay off of the ESXi console and get the disk UUIDs with a minor adjustment to the code in this post. Say, like:<br /><br />Insert a new property in the hashtable (say, insert this next line after the current line 37 in the code):<br /> HardDiskUUID = $hdThisDisk.Backing.LunUuid<br /><br />And, update the array of property names to select (replace current line 45 with this):<br /> $arrPropertiesToSelect = "VMName,HardDiskName,HardDiskUUID,ScsiId,DeviceDisplayName,SizeGB,ScsiCanonicalName".Split(",")<br /><br />That should work out just right. Does it?<br /><br />Enjoy,<br /><br />MattMattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-76680384327094840372016-04-05T04:27:41.814-04:002016-04-05T04:27:41.814-04:00Hello, Can we get VM's each disks UUID..
Norma...Hello, Can we get VM's each disks UUID..<br />Normally we use VMKFSTOOLS command to get ..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-19591527074027885012015-02-24T21:38:26.793-05:002015-02-24T21:38:26.793-05:00Anon - Here is a known working line in my script t...Anon - Here is a known working line in my script that pulled disk info form vNugglets. The "Name"="^[a-zA-Z1-9]" is the regex part. If the vm starts with a zero then I don't want it. You may want ^[xx] starts with xx. <br /><br />$vm = get-view -ViewType VirtualMachine -Filter @{“Runtime.PowerState”=”poweredOn”;”Config.Template”=”false”;"Name"="^[a-zA-Z1-9]"} -SearchRoot $(get-view -ViewType Datacenter -Property Name -Filter @{“Name” = “MyDC”}| select -ExpandProperty MoRef)<br />Kattraphttps://www.blogger.com/profile/13734400717376941957noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-57927995245471917192015-02-11T09:47:44.212-05:002015-02-11T09:47:44.212-05:00Thanks for sharing scripts,
I'm trying to pul...Thanks for sharing scripts,<br /><br />I'm trying to pulling out more than one vm information with regular expression like vmName "xx1", "xx2", "xx3" it doesn't work ,<br />second things i wanted to pull out DeviceDisplayName and ScsiCanonicalName for regular VMDK <br /><br />Greatly appreciate if you can help me out <br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-39357413674337085332014-12-09T22:40:53.844-05:002014-12-09T22:40:53.844-05:00Hello, MrSulik-
Thanks, glad that you are enjoyin...Hello, MrSulik-<br /><br />Thanks, glad that you are enjoying it! As for adding those other properties that you mentioned, you could add the following few lines into the code at the corresponding spots:<br />After Line 42, add:<br /> Id = "{0}/{1}" -f $viewVMForStorageInfo.MoRef.ToString(), $hdThisDisk.Key<br /> DiskType = $(<br /> if ($hdThisDisk.Backing -is [VMware.Vim.VirtualDiskFlatVer2BackingInfo]) {"Flat"}<br /> elseif ($null -ne (Get-Member -InputObject $hdThisDisk.Backing -Name compatibilityMode)) {"Raw{0}" -f (Get-Culture).TextInfo.ToTitleCase(($hdThisDisk.Backing.compatibilityMode -replace "mode",""))}<br /> else {$null})<br /><br /><br /><br />And, replace the line originally at Line 45 with the following:<br /> $arrPropertiesToSelect = "VMName,HardDiskName,ScsiId,DeviceDisplayName,SizeGB,ScsiCanonicalName,Id,DiskType".Split(",")<br /><br /><br />Enjoy some more!<br />MattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-20951489500501680052014-11-25T10:12:19.809-05:002014-11-25T10:12:19.809-05:00Excellent Script! Thanks a lot for that!
I would ...Excellent Script! Thanks a lot for that!<br /><br />I would like to add two other properties from get-harddisk to your script, but can't figure out how:<br />the disk ID and the disk type (rawvirtual, rawphysical, flat).<br /><br />How would I add those two to your script?MrSuliknoreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-22000176416247593342014-10-26T19:00:58.945-04:002014-10-26T19:00:58.945-04:00Hello, Brandon-
Good, glad that it helped!
As fo...Hello, Brandon-<br /><br />Good, glad that it helped!<br /><br />As for the "get exact matches change" -- yes, that is a way to get exact matches. Though, it has a downfall of slowing down the show: the -Filter way does the filtering at the vCenter server, whereas the Where-Object way returns the View object for _all_ VMs and _then_ does the filtering at the client side.<br /><br />As for getting exact matches with the way that the function is written, you can use standard regular expression anchors. So, if you have myvm1 and myvm10, and want to only get disk/RDM info for myvm1, you can use the following value for the $vmName parameter: "^myvm1$". That means that the VM name must start with the "m" character, and end with the "1" character, and that is the entire pattern (instead of matching in the "contains" style that you mention).<br /><br />Btw -- part of the reason for having written the function to use regular expressions was so that people could get clever in any way they desired with regular expressions, instead of constraining them to using standard wildcarding.<br /><br />Anyway, give that a shot, and see how it does for you (and, if you have a very large environment/inventory, you should notice the speed difference, too, with the -Filter vs. the Where-Object).<br /><br />Thanks for the comment!MattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-68464544079860626982014-10-24T15:41:05.956-04:002014-10-24T15:41:05.956-04:00Thanks for the function, saved me a ton of time wr...Thanks for the function, saved me a ton of time writing one up for something similar!<br /><br />I wanted to note, that to get exact matches change line 22 to:<br /><br />$arrVMViewsForStorageInfo = Get-View -Viewtype VirtualMachine -Property Name, Config.Hardware.Device, Runtime.Host | Where-Object {$_.Name -eq "$vmName_str"}<br /><br />This is very useful if you're looping through a large number of VMs where there may be mulitple matches for a given string. It seems to be running a "contains" search as-is.Brandonhttps://www.blogger.com/profile/13776518752719860158noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-40000504169607974192014-10-23T21:05:42.165-04:002014-10-23T21:05:42.165-04:00Hello, Tony-
Thanks! As for the $null values for...Hello, Tony-<br /><br />Thanks! As for the $null values for the DeviceDisplayName and ScsiCanonicalName properties -- that is due to the type of virtual disk. Those value will be empty for "regular" virtual disks, only populated for RDMs.<br /><br />In the example in the post, you see that Hard Disk 1 has no values for those two properties, and Hard Disk 2 has values. That is because that VM has an RDM for Hard Disk 2. The properties are of the SCSI LUN that backs the RDM. Make sense?MattBoren (@mtboren)https://www.blogger.com/profile/08371304528581535245noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-28044778677632869262014-10-14T11:12:06.231-04:002014-10-14T11:12:06.231-04:00Nice Function. I have noticed that there is no ou...Nice Function. I have noticed that there is no output values for DeviceDisplayName or ScsiCanonicalName. I have not gotten any errors so I am not sure if there is something that may need adjusting. <br /><br />any thoughts?Anonymoushttps://www.blogger.com/profile/13737401049525747965noreply@blogger.comtag:blogger.com,1999:blog-2269516327950490847.post-31429320090638803212014-06-17T06:42:47.794-04:002014-06-17T06:42:47.794-04:00Very nice post! Thanks!Very nice post! Thanks!Anonymousnoreply@blogger.com