Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 1.0 » Add-Content

Add-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 »

Add-Content

Description
Get content from item (specific location)

Usage


Options


Example(s)
1) Add a text string to the end of every .TXT file in the current directory:

C:\PS>add-content -path *.txt -value "This is the end"

2) Add the content of the file Cats.txt to the end of the file Pets.txt:

C:\PS>add-content -path pets.txt -value (get-content c:\docs\cats.txt)

The parentheses above insure Get-Content can complete before the Add-Content starts.
We specify -value to pass the contents of the file (rather than an object.)

3) Add the current date to a logfile:

C:\PS>add-content -Path MyLogfile.txt -Value (get-date) -passthru

The -passthru option will display the content as it is added, it actually passes an object through the pipeline, which by default is passed back to the command line.