Powershell experince 3 hours...
Scenario: need to add a line of code to the top of multiple ASPX files in multiple folders and subfolders
Is this possible?
I've figured out how to search for the files but adding that line of code is where I'm stuck. This is what I have, which is not working
Get-ChildItem C:\domain_3 -recurse -include "*.aspx" |
Foreach-Object {
Add-Content -Path $targetFile -Value "<%@ Page Language="C#" Inherits="LandingPages.LandingPage" %>";
}
Thank you all
$header=@"
"<%@ Page Language="C#" Inherits="LandingPages.LandingPage" %>
"@
Get-ChildItem C:\domain_3 -Recurse -Filter *.aspx | Foreach-Object {
$header`n" + (Get-Content $_.FullName | Out-String) | Set-Content -Path $_.FullName
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With