Skip to content

Commit bb8708c

Browse files
author
Ajay Dwivedi
committed
Adding one more powershell script
Adding one more powershell script
1 parent 3e1c647 commit bb8708c

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
2.5 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
$path = 'E:\GitHub\SQLDBA-SSMS-Solution'
2+
3+
$files = Get-ChildItem -Path $path -Recurse -File
4+
5+
#$files | select * -First 1
6+
7+
# read content
8+
$files_readable = $files | Where-Object {$_.Extension -in @('.md','.sql','.ps1','.xml','.txt')}
9+
$files_noIssue = [System.Collections.ArrayList]@();
10+
$files_Issue = [System.Collections.ArrayList]@();
11+
foreach($file in $files_readable) {
12+
$fullName = $file.FullName;
13+
$fc = Get-Content -LiteralPath $fullName;
14+
15+
if($fc -match "tivo") {
16+
Write-Host "Found => $fullName" -ForegroundColor Red -BackgroundColor White
17+
$fc | ForEach-Object {$_ -replace "tivo", 'contso'} | Set-Content -LiteralPath $fullName;
18+
$files_Issue.Add($fullName) | Out-Null;
19+
#break
20+
#$Matches
21+
} else {
22+
#Write-Host "$fullName" -ForegroundColor Green
23+
$files_noIssue.Add($fullName) | Out-Null;
24+
}
25+
#break;
26+
}
27+
28+
#$files_noIssue | ogv -Title 'Files without any issue';
29+
$files_Issue | ogv -Title 'Files with issue';

PowerShell Commands/PowerShell Commands.ssmssqlproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
<AssociatedConnUserName />
7474
<FullPath>EnhancedHtml.sql</FullPath>
7575
</FileNode>
76+
<FileNode Name="Find-and-Replace-Text-All-Files.sql">
77+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
78+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
79+
<AssociatedConnUserName />
80+
<FullPath>Find-and-Replace-Text-All-Files.sql</FullPath>
81+
</FileNode>
7682
<FileNode Name="Find-ChangedDatabases-Since-Date.sql">
7783
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
7884
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>

0 commit comments

Comments
 (0)