compare
2 TopicsLesson Learned #502: Comparing and Transferring Azure SQL Databases Table Structures Using SMO
This last week, I worked on a service request that we need to compare the existing tables of a database placed on a Azure SQL Server with another hand. If the table doesn't exist in the target database the intention is to have a script of the table and recreate the table in the target. Following, I would like to share my lessons learned here.1.7KViews0likes0CommentsUse an arraylist in a comparison operation
Hello, here is a short code. $infos = $null $infos = @{} $infos = @{ "toto" = "tutu" ; "hello" = "hellu" <#...#> } $extensions = $null $extensions = New-Object -TypeName 'System.Collections.ArrayList'; $extensions = ("txt", "cmd","ps1" <#...#>) foreach ($key in $infos.keys) { $key Get-ChildItem ".\Desktop\test" -Recurse | Where-Object {-not $_.PSIsContainer -and ($_.Extension -eq ".frm" -or $_.Extension -eq ".ps1" -or $_.Extension -eq ".txt")} | ForEach-Object {(Get-Content $_.FullName) | ForEach-Object { $_ -replace [regex]::Escape($key), $($infos[$key]) } | Set-Content $_.FullName } } I want to use an arraylist containing a list of file extensions when I do my extensions checks in there: -and ($_.Extension -eq ".frm" -or $_.Extension -eq ".ps1" -or $_.Extension -eq ".txt") I'd like to replace it with something similar to: -and ($_.Extension -eq $extensions) Is there anyway clean way to writting this? Thank you!Solved811Views0likes2Comments