Lewis
Lewis

Reputation: 2453

Storing output into a dictionary

I want to iterate through the folders inside the patch scripts, find every iterated result of DBChangesMain and ContentLbl and store it into a dictionary or hash table, and then print out the results how do i do this?

So far I have

$patchscripts = Get-Item "F:\folder\trunk\Source\Database\Patch Scripts" 

foreach ($folders in Get-childitem $patchscripts -recurse -include *.sql )
{        
    if ($folders -like "*DBChangesMain*")
    {   

    }
    if ($folders -like "*ContentLbl*")
    {       

    }      
}

 Write-Host $DbChanges
 Write-Host $contentlbl 

if you have a better way of doing this, please let me know, cheers.

Upvotes: 1

Views: 926

Answers (1)

Joey
Joey

Reputation: 354694

I guess after your comments I'd rather go the following route:

$patchscripts = 'F:\folder\trunk\Source\Database\Patch Scripts'
$dbChangesMain = Get-ChildItem $patchScripts -Rec -Inc *DBChangesMain*.sql
$contentLbl = Get-ChildItem $patchScripts -Rec -Inc *ContentLbl*.sql

Afterwards you simply have two arrays containing the matching names of the SQL files.

Upvotes: 2

Related Questions