When the script runs I dynamically reference a hashtable member by searching through the hashtable to get its key (or name depending on what you call it). Once I have this value I pass to a Where clause (highlighted in the red below).
# Get logical disks Get-WmiObject -Class Win32_LogicalDisk | % { switch($_.VolumeName) { Vol1 { # Set dates $startdate = ($volumedateranges.GetEnumerator() | Where {$_.key -match $_.VolumeName}).Value[0] $enddate = ($volumedateranges.GetEnumerator() | Where {$_.key -match $_.VolumeName}).Value[1]
# Get directories from switched drive Get-ChildItem -Path "$($_.DeviceID)*Data*" | ` Where {($_.PSIsContainer) -and (Get-FolderDate $_.fullname -lt $startdate) -and (Get-FolderDate -gt $enddate)} | ` Select $_.fullname } Vol2 { # Set dates $startdate = ($volumedateranges.GetEnumerator() | Where {$_.key -match $_.VolumeName}).Value[0] $enddate = ($volumedateranges.GetEnumerator() | Where {$_.key -match $_.VolumeName}).Value[1]
# Get directories from switched drive Get-ChildItem -Path "$($_.DeviceID)*Data*" | ` Where {($_.PSIsContainer) -and (Get-FolderDate $_.fullname -lt $startdate) -and (Get-FolderDate -gt $enddate)} | ` Select $_.fullname } } }
mjolinor pointed out I can bypass the enumeration and use the key (name) directly within my hashtable reference with this syntax: