Powershell 5.1 | How to Create/Delete/Move/Copy files & Folders (Items) using Powershell

Hey Friends!! I hope you all are doing well!!

This is my first post on Powershell, so I thought of starting with files and folders.

Today we will learn below actions using Powershell 5.1

Create a folder

Create a file

Getting the content of a file

Getting content of a folder

Copy a file to a different location

Move a file to a different location

Delete file

Delete folder


Before you start ensure Powershell 5.1 version is installed as the LAB done using 5.1. and as on today this is the least version you should have. 😊

If you do not have OR want to upgrade download the Powershell 5.1 from below location and install/upgrade


Let’s start!!

Create a folder

      To create a folder use below command

       Folder name- Test_Folder_1

Folder name- Test_Folder_2

If you want to verify in the current directory (In this case I am in C:\) , you will see as below

Create a file

   Go to Test_Folder_1 using below command

Create a text file using below command, similarly create Test_file_2.txt in Test_Folder_2

Getting the content of a file

     To see what’s inside a file,

Getting content (listing) of a folder

Getting content(listing) of a folder recursively, the result will give nested folder contents as well

Copy a file to different location

We will copy Test_File_2.txt to C:\Test_Folder_1, So the command is as below

Move a file to different location

     We will move Test_File_1.txt to C:\Test_Folder_2

Delete a file (Here we deleted Test_File_2.txt)

Delete a folder (Here we deleted Test_Folder_2)

Note: if a folder contains various files and nested folders it will ask for confirmation as below. Type Y and press enter , it will completely delete the folder with all its contents.

But if you use recurse switch as shown below it will not ask for any confirmation and delete the folder will all its contents.

That’s it for today Guys. I think have given you useful information and steps…

Cheers!!! Please do share if you like it!! Thanks…