Skip to content

RAI4301_0001: Deleting a file from Windows with Powershell

Summary

ID RAI4301_0001
Brief Description Removing a file from a Windows system through the Powershell
Author e6e6e@Cyberok
Creation Date 2023/03/22
Modification Date 2023/03/30
Requirements
  • software
Tags
  • Delete File
Means of action
Targets of action
Linked Response Actions

Description

To delete the file using PowerShell, we can use the Remove-Item command. Remove-Item command removes the file from the path specified. For example, we have the file with path: C:\Test\Test.txt.

To delete the file use the below command.

Remove-Item 'C:\Test\test.txt'

This command deletes a file that's both hidden and read-only.

Remove-Item -Path C:\Test\hidden-RO-file.txt -Force

It uses the Path parameter to specify the file. It uses the Force parameter to delete it. Without Force, you can not delete read-only or hidden files Microsoft/Powershell