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:
Why enumerate when I can just call directly. Much less work, more direct, and, cleaner for sure. Thanks again hammer man.
About lamsim
Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.