One of my routines at office include running a Bat file ocacctionaly and after that i have to do a manual change to few files to be able to run my VS project in debug mode. But i always forget to do the manual step and i have to start over so i decied to create aPowerShell script to combine the two. This is my first time to use PowerShell and i had no clue about the IDE or Syntex to here is how i got into the flow.
My first action was to write powershell in windows 8 and i ended up with this
but i was like “where is the IDE with all the menus i heard about” so google told me that i should use powershell ISE which is located under Administrative Tools. So i got this. I will explaing the IDE in another blog post as this is focused to Almost my “Hello World Version”
So To launch the bat file i wrote this command
Write-Host –NoNewLine "Hello lazy " Start-Process 'C:\Data\script.bat' $userinput = Read-Host " Hello lazy : Press Enter to fix the config files" $word = "string to replace" $replacement = "new string " (Get-Content C:\Data\hgdata\web.config) | Foreach-Object {$_ -replace $word,$replacement} | Out-File C:\Data\hgdata\web.config $userinput = Read-Host "Press any key to exit"
and thats it. I will explaing in detail about ISE, IDE and different functions used here.