- PowerShell Tutorial
- PowerShell - Home
- PowerShell - Overview
- PowerShell - Environment Setup
- PowerShell - Cmdlets
- PowerShell - Files and Folders
- PowerShell - Dates and Timers
- PowerShell - Files I/O
- PowerShell - Advanced Cmdlets
- PowerShell - Scripting
- PowerShell - Special Variables
- PowerShell - Operators
- PowerShell - Looping
- PowerShell - Conditions
- PowerShell - Array
- PowerShell - Hashtables
- PowerShell - Regex
- PowerShell - Backtick
- PowerShell - Brackets
- PowerShell - Alias
- PowerShell Useful Resources
- PowerShell - Quick Guide
- PowerShell - Useful Resources
- PowerShell - Discussion
Powershell - Retrieving Item
Cmdlet
Get-Content cmdlet is used to retrieve content of a file as an array.
Example 1
In this example, we'll read a file D:\Temp\Test\Test.txt
Type the following command in PowerShell ISE Console
Get-Content D:\temp\Test\test.txt
Output
You can see following output in PowerShell console.
Get-Content D:\temp\test\test.txt ;This is a test file.
Example 2
In this example, we'll read the size of the content of the file read.
Type the following command in PowerShell ISE Console
(Get-Content D:\temp\test\test.txt).length
You can see following output in PowerShell console.
(Get-Content D:\temp\test\test.txt).length 20
powershell_files_folders.htm
Advertisements