Sleep or Pause to PowerShell Script

Last Updated on August 7, 2025 by Arnav Sharma

In PowerShell, the move-item cmdlet stands out as a powerful tool to move a file or an entire directory from one location to another. By utilizing parameters like -path to specify the source and -destination to indicate the target, users can effortlessly move all files, including those within subfolders. The get-childitem cmdlet can be paired with move-item -destination to fetch a file name or a list of items, streamlining the process. In essence, the following command exemplifies the seamless integration of cmdlets to manage and relocate files and directories.

# Prompt user for the action (1 for copy, 2 for move)
$action = Read-Host "Enter the action (1 for copy, 2 for move)"

# Prompt user for the source path
$sourcePath = Read-Host "Enter the source path"

# Prompt user for the destination
$destinationPath = Read-Host "Enter the destination path"

# Take action based on user's choice
if ($action -eq "1") {
    # Copy files and folders
    Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse
    Write-Host "Files and folders copied successfully from $sourcePath to $destinationPath."
} elseif ($action -eq "2") {
    # Move files and folders
    Move-Item -Path $sourcePath -Destination $destinationPath -Recurse
    Write-Host "Files and folders moved successfully from $sourcePath to $destinationPath."
} else {
    Write-Host "Invalid action selected."
}

Usage:

 PowerShell move-item cmdlet emerges as a critical tool. Whether you’re using PowerShell 5.1, PowerShell 7, or any other version, this cmdlet is used to move files or folders from one location to another location. Say you want to move a single file or need to move multiple files, such as text files or PDF files, based on their extensions; the move-item cmdlet in PowerShell has got you covered. By specifying the path of the file and the destination folder, you can easily move your files. Moreover, if there’s an existing file in the destination with the same name, the command offers options to overwrite, ensuring seamless move operations.

For those who want to move all the files from the current directory or maintain the folder structure by moving all files and subfolders recursively, the move-item cmdlet paired with parameters like passthru and recursively is the answer. Additionally, using the wildcard feature, users can filter files or see which files will be moved without actually performing the move.

In scenarios where you have an existing file in the destination or want to move the entire source folder, PowerShell provides options to handle overwriting existing files or preserving the original location. In essence, if you’re looking to harness the power of the command line for moving files in PowerShell, use the following command structures and techniques to ensure efficient and accurate file transfers.

13 thoughts on “PowerShell – Copy or Move Files and Folders”
  1. Great post! I found the examples of using PowerShell to copy and move files incredibly helpful. It’s amazing how much simpler these tasks can be with the right commands. Looking forward to more tutorials like this!

  2. Great post! I love how you broke down the steps for using PowerShell to copy and move files. The examples were super helpful, especially for someone like me who’s just starting to get familiar with PowerShell scripting. Looking forward to more tutorials!

  3. Great post! I learned a lot about using PowerShell for file management. The examples were really clear and easy to follow. Can’t wait to try these techniques in my own scripts!

  4. This is a fantastic post! I never realized how flexible PowerShell is for file management. The examples are clear and really help me understand the differences between Copy and Move commands. Can’t wait to try these out in my own workflows! Thanks for sharing!

  5. Great post! I learned a lot about using PowerShell for file management. The examples were clear and really helped me understand the difference between copying and moving files. Looking forward to more tips like this!

  6. Great post! I love how you broke down the commands for copying and moving files. The examples were super helpful for me as Iโ€™m just starting to use PowerShell. Looking forward to more tutorials like this!

  7. Great post! I learned a lot about using PowerShell for file management. The examples were really helpful, especially the comparison between Copy-Item and Move-Item. Looking forward to more tips like this!

  8. I loved this post! The detailed examples on how to use PowerShell for copying and moving files made it super easy to understand. I had no idea about the `-Recurse` parameter for directories โ€“ thatโ€™s going to save me so much time! Looking forward to more tutorials like this!

  9. This post was super helpful! I always struggled with file management in PowerShell, but your clear examples made it so much easier to understand. Can’t wait to try out the commands you shared!

  10. Great post! I learned some handy tips about file management in PowerShell. The examples you provided made it easy to understand how to effectively use the Copy and Move commands. Looking forward to trying these out in my own scripts!

  11. Great post! I learned some useful PowerShell commands for managing files and folders. The examples made it easy to follow along. Thanks for sharing!

  12. Great post! I learned a lot about using PowerShell to manage files and folders more efficiently. The examples were super helpful. Looking forward to more tutorials like this!

  13. This post is incredibly helpful! Iโ€™ve always struggled with file management using PowerShell, but your clear examples make it so much easier to understand. Canโ€™t wait to try these commands out in my scripts! Thank you for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.