Files in PowerShell

Contents
Introduction
New-Item: create new file
Create new file with echo
Copy-Item: copy file
Remove-Item: delete file
Get-Content -Tail: file ending
Get-FileHash: control sum
Related Articles

New-Item

Example of creating a config.yml file with New-Item command

New-Item -Path . -Name "config.toml" -ItemType "file"

Example of creating a PowerShell configuration file

New-Item -Path $profile -Force -ItemType "file"

Create file with echo

echo $null >> new_file.txt

Copy-Item

To copy a file from the current directory to a nested one, run

Copy-Item -Path "file_name" -Destination "имя_директории"

For example

Copy-Item -Path "requirements.txt" -Destination "autotest_distr"

Remove-Item

You can delete a file with the Remove-Item command

Delete all files from the directory C:\Test which have a dot in their name

Remove-Item C:\Test\*.*

A script that deletes a Python .exe file from WinodwsApps

# DeletePythonFromWindowsApps.ps1 $CURRENT_USER = $Env:Username $PYPATH = 'C:\Users\' + $CURRENT_USER + '\AppData\Local\Microsoft\WindowsApps\python.exe' $PY3PATH = 'C:\Users\' + $CURRENT_USER + '\AppData\Local\Microsoft\WindowsApps\python3.exe' If (Test-Path -path ${PYPATH}) { Remove-Item $PYPATH } If (Test-Path -path ${PY3PATH}) { Remove-Item $PY3PATH }

Get-Content

You only need to look at the end of the file by analogy with tail in Linux you can use Get-Content with the -Tail flag.

For example, to get the last 100 lines of a file 2026-10-17.log

Get-Content -Path "C:\logs\2026-10-17.log" -Tail 100

If you need the real time log, use the -Wait flag

Get-Content -Path "C:\logs\2026-10-17.log" -Wait

You can combine -Wait and -Tail and monitor only the last lines in real time

Get-Content -Path "C:\logs\2026-10-17.log" -Wait -Tail

Get-FileHash

To check the checksum of a file in PowerShell, just run

Get-FileHash путь_до_файла -Algorithm MD5

This is an analogue Bash md5sum commands in Linux and md5 in OpenBSD

Check the notes.txt file in the current directory

Get-FileHash notes.txt -Algorithm MD5

--------- ---- ---- MD5 14B17234E237534421B6492B8D757507 C:\Users\andrei\Downlo…

Article author: Andrei Olegovich

Related articles
Windows
PowerShell
Install
Basics
Alias
Functions
Network
Users
Files
REST API requests
Errors

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: