Files in PowerShell

Содержание
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-04.log

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

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

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

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

Get-Content -Path "C:\logs\2026-10-04.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

Похожие статьи
Windows
PowerShell
Install
Basics
Alias
Functions
Network
Users
Files
REST API requests
Errors

Поиск по сайту

Подпишитесь на Telegram канал @aofeed чтобы следить за выходом новых статей и обновлением старых

Перейти на канал

@aofeed

Задать вопрос в Телеграм-группе

@aofeedchat

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящую по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: