Set-Content - Powershell 1.0 CmdLet
ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »
Set-Content
Description
Set content in the item (specific location)
Usage
Options
Example(s)
Write a string into a text file:
PS C:\>Set-content -path C:\test.txt -value "Hello World"
Write the current date into a CSV file:
PS C:\>get-date | set-content C:\Test_date.csv
Edit-Replace some text in every line of the file foo.txt :
PS C:\>(get-content foo.txt) | foreach-object {$_ -replace "oldTxt", "newTxt"} | set-content foo.txt
The parentheses around (Get-Content) ensure that the Get operation is completed before the Set operation begins, wthout this the two functions would both try to access the file at the same time.
