VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

Script to find .ISO files in all of my datastores ?

Hi People,

Can anyone please assist me in finding any .ISO files spread across my datastore with powershell script for both local datastore and SAN ?

Thanks,

AWT

/* Please feel free to provide any comments or input you may have. */
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Format-Table -AutoSize cmdlet only shows output on screen when all objects are received.

It can take very long before you see anything on screen due to the size of your datastores.

Try it this way

dir vmstores:\ -Recurse -Include *.iso | Select Name,FolderPath


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

5 Replies
mattboren
Expert
Expert
Jump to solution

Hello, AlbertWT-

That is pretty straightfoward, thanks to the PSDrive "vmstores:\" that gets created in your PowerCLI session (specifically, when the VMware.VimAutomation.Core PSSnapin gets added to the session).  This PSDrive is created using the VimDatastore provider, and provides access to all of the datastores in all of the VIServers to which you are connected via Connect-VIServer.

So, you can use a "dir" (alias for Get-ChildItem) to find the ISOs that you desire:

dir vmstores:\ -Recurse -Include *iso | ft -a

There are other ways to search datastores, but this should suit the need you mentioned.  How does that do for you?

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Hi Matt,

It doesn't show up anything ?

I'm using PowerGUI Script Editor with the following configurations:

PS Microsoft.PowerShell.Core\FileSystem::\\FileServer01\homedir\Albert> Get-PowerCLIVersion | ft -AutoSize
Major Minor  Build Revision Copyright                          Company      UserFriendlyVersion                         SnapinVersions                              
----- -----  ----- -------- ---------                          -------      -------------------                         --------------                              
    4     1 332441        0 Copyright © VMware, Inc. 1998-2010 VMware, Inc. VMware vSphere PowerCLI 4.1 U1 build 332441 {VMWare vSphere PowerCLI 4.1 U1 build 332441}
PS Microsoft.PowerShell.Core\FileSystem::\\FIleServer01\homedir\Albert> Get-PowerCLIConfiguration | ft -AutoSize
Proxy Policy   Default Server Mode
------------   -------------------
UseSystemProxy Multiple          
PS Microsoft.PowerShell.Core\FileSystem::\\FileServer01\homedir\Albert> Get-PSProvider | ft -AutoSize
Name         Capabilities                Drives            
----         ------------                ------            
WSMan        Credentials                 {WSMan}           
Alias        ShouldProcess               {Alias}           
Environment  ShouldProcess               {Env}             
FileSystem   Filter, ShouldProcess       {C, D, G, H...}   
Function     ShouldProcess               {Function}        
Registry     ShouldProcess, Transactions {HKLM, HKCU}      
Variable     ShouldProcess               {Variable}        
Certificate  ShouldProcess               {cert}            
VimDatastore ShouldProcess               {vmstores, vmstore}
VimInventory Filter                      {vis, vi}         
PS Microsoft.PowerShell.Core\FileSystem::\\FileServer01\homedir\Albert> Get-PSSnapin | ft -AutoSize
Name                                             PSVersion Description                                                                                                            
----                                             --------- -----------                                                                                                            
Microsoft.PowerShell.Diagnostics                 2.0       This Windows PowerShell snap-in contains Windows Eventing and Performance Counter cmdlets.                             
Microsoft.WSMan.Management                       2.0       This Windows PowerShell snap-in contains cmdlets (such as Get-WSManInstance and Set-WSManInstance) that are used by t...
Microsoft.PowerShell.Core                        2.0       This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.                      
Microsoft.PowerShell.Utility                     2.0       This Windows PowerShell snap-in contains utility Cmdlets used to manipulate data.                                      
Microsoft.PowerShell.Host                        2.0       This Windows PowerShell snap-in contains cmdlets (such as Start-Transcript and Stop-Transcript) that are provided for...
Microsoft.PowerShell.Management                  2.0       This Windows PowerShell snap-in contains management cmdlets used to manage Windows components.                         
Microsoft.PowerShell.Security                    2.0       This Windows PowerShell snap-in contains cmdlets to manage Windows PowerShell security.                                
Quest.ActiveRoles.ADManagement                   1.0       This Windows PowerShell snap-in contains cmdlets to manage Active Directory and Quest ActiveRoles Server.              
VMware.VimAutomation.Core                        2.0       This Windows PowerShell snap-in contains Windows PowerShell cmdlets for managing vSphere.                              
Microsoft.Exchange.Management.PowerShell.Admin   1.0       Admin Tasks for the Exchange Server                                                                                    
Microsoft.Exchange.Management.Powershell.Support 1.0       Support Tasks for the Exchange Server                                                                                  

I can use any other PS script in this forum but somehow even the simple "dir vmstores:\" command not working either ?

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Format-Table -AutoSize cmdlet only shows output on screen when all objects are received.

It can take very long before you see anything on screen due to the size of your datastores.

Try it this way

dir vmstores:\ -Recurse -Include *.iso | Select Name,FolderPath


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Yes it works without the ft -autosize.

Thanks to all who reply to my thread.

Cheers,

AWT

/* Please feel free to provide any comments or input you may have. */
0 Kudos
aaronmiller85
Enthusiast
Enthusiast
Jump to solution

Just wanted to say thanks for the powercli snippet! Really comes in handy

0 Kudos