Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. param(
  2. [Parameter(Mandatory=$true, ParameterSetName="Path", Position=0,HelpMessage='Data folder Path')]
  3. [string] $Path,
  4.  
  5.  
  6. [Parameter(Mandatory=$true, HelpMessage='Input the string to be replaced')]
  7. [string] $Input,
  8.  
  9. [Parameter(Mandatory=$true,HelpMessage='Input the new string that need to be replaced')]
  10. [string] $Replace
  11.  
  12. )
  13.  
  14. $a = Test-Path $Path
  15. IF ($a -eq $True) {Write-Host "Path Exists"} ELSE {Write-Host "Path Doesnot exits"}
  16. $configFiles = Get-ChildItem -Path $Path -include *.pro, *.rux -recurse
  17. $Append = join-path -path $path *
  18. $b = test-path $Append -include *.pro, *.rux
  19. If($b -eq $True) {
  20. foreach ($file in $configFiles)
  21. {
  22. (Get-Content $file.PSPath) |
  23. Foreach-Object { $_ -replace [regex]::Escape($Input), $Replace } |
  24. Set-Content $file.PSPath
  25. }
  26. $wshell = New-Object -ComObject Wscript.Shell
  27. $wshell.Popup("Operation Completed",0,"Done",0x0)
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement