Hi,
New to VM, but have been lurking in the background. 🙂 I would like to see what is contained on each LUN via PowerCLI without having to go to Vcenter and browse datastore, I want the browse datastore info. via CLI.
Hope this makes sense.
Thanks
Hello-
Well, "vmstore" is not a directory, but rather a PowerShell drive (a PSDrive). So, when you cd or Set-Location to "vmstore:", it is similar to setting the location to the 😧 drive. You could use "cd d:\" to change to the 😧 PSDrive.
To try to shed more light on this, you can use the Get-PSDrive cmdlet to list all of the current PSDrives in your PowerShell session, like:
PS C:\> Get-PSDrive
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
Alias Alias
C 31.76 31.62 FileSystem C:\
cert Certificate \
D 393.04 538.47 FileSystem D:\
...
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
...
vmstore VimDatastore \LastConnectedVCenterServer
vmstores VimDatastore \
...
Examples of the PSDrives in your PowerShell session: the Windows volumes on your machine ("C:\", "D:\", etc.), Functions and Variables defined in your PowerShell session ("Function:\" and "Variable:\"), the Windows registry on your machine ("HKLM:\" and "HKCU:\" -- HKeyLocalMachine and HKeyCurrentUser), and so on. To navigate to any of those, you can use Set-Location or the alias "cd".
So, you should be able to do a "cd vmstore:\" to initially get to the "vmstore" PSDrive. How does that do?
Hello, Dlouw-
Welcome to the communities.
Yes, makes sense. You can use the "vmstore:" PSDrive to navigate- and browse datastores like you would any other filesystem.
PS C:\> cd vmstore:
PS vmstore:\> dir
Name Type Id
---- ---- --
myDataCenter0 Datacenter Datacenter-d...
myDataCenter1 Datacenter Datacenter-d...
PS vmstore:\> dir .\myDataCenter0\
Name FreeSpaceMB CapacityMB
---- ----------- ----------
daterstore01 321978 476672
ssd01 27132 261632
PS vmstore:\> cd .\myDataCenter0\daterstore01
PS vmstore:\myDataCenter0\daterstore01> dir
Datastore path: [daterstore01]
LastWriteTime Type Length Name
------------- ---- ------ ----
9/11/2011 1:13 PM Folder win7test
9/9/2011 10:43 PM Folder testtmpl
9/18/2011 11:45 PM Folder blahh0
11/25/2011 4:00 PM Folder win7test2
12/7/2011 2:56 PM Folder testTemplate
...
The last "dir" above listed the VMs' folders on the given datastore. You could "cd" (alias for Set-Location) into one of the VMs' folders and list its contents as desired.
This "vmstore:" PSDrive gets created with the VimDatastore provider when you add the VMware.VimAutomation.Core PSSnapin to your PowerShell session (manually, via your profile, whatever). Enjoy.
Thanks for the very prompt reply, I will try and figure out how to do what you have said... 🙂
Is this method still applicable if my hosts are on blades and the storage is on LH nodes?
Hello, Dlouw-
Yes, this should be the same, regardless of the hosts' physical hardware and the storage backend. As long as the datastores are visible in vCenter, you should be able to navigate them in this manner.
A couple of notes:
How does that do for you?
Thanks, I don't see the vmstore directory??
Hello-
Well, "vmstore" is not a directory, but rather a PowerShell drive (a PSDrive). So, when you cd or Set-Location to "vmstore:", it is similar to setting the location to the 😧 drive. You could use "cd d:\" to change to the 😧 PSDrive.
To try to shed more light on this, you can use the Get-PSDrive cmdlet to list all of the current PSDrives in your PowerShell session, like:
PS C:\> Get-PSDrive
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
Alias Alias
C 31.76 31.62 FileSystem C:\
cert Certificate \
D 393.04 538.47 FileSystem D:\
...
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
...
vmstore VimDatastore \LastConnectedVCenterServer
vmstores VimDatastore \
...
Examples of the PSDrives in your PowerShell session: the Windows volumes on your machine ("C:\", "D:\", etc.), Functions and Variables defined in your PowerShell session ("Function:\" and "Variable:\"), the Windows registry on your machine ("HKLM:\" and "HKCU:\" -- HKeyLocalMachine and HKeyCurrentUser), and so on. To navigate to any of those, you can use Set-Location or the alias "cd".
So, you should be able to do a "cd vmstore:\" to initially get to the "vmstore" PSDrive. How does that do?
Okay, so you are officially the man!!!! THANKS
One last question, how do I send the ouput / results to a txt file?
Answered my own question - Thanks for all the help.