PowerShell locking File....
- by Ben
I am trying to do something very simple in powershell
Reading the contents of a file
Manipulation some string
Saving the modified test back to the file
function Replace {
$file = Get-Content C:\Path\File.cs
$file | foreach {$_ -replace "document.getElementById", "$"} |out-file -filepath C:\Path\File.cs
}
I have tried Set-Content as well.
I always get unautorized exception. I can see the $file has the file content, error is coming while writing the file.
Any help is appreciated.
Ben