Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:09:16+00:00 2026-05-26T07:09:16+00:00

I am new to PowerShell. When trying to write a simple script that deletes

  • 0

I am new to PowerShell. When trying to write a simple script that deletes the contents of a folder and then fills it with files copied from a different folder, I always get a PermissionDenied error.

Details:

+ remove-item <<<<  D:\path\* -recurse
    + CategoryInfo : PermissionDenied: (save.gif:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

Where is the problem? I am able to manipulate both folders through Explorer.
The error occurs both when running from a script file and from shell (using Windows PowerShell ISE).
The ISE process runs under my account.
I’m running Windows 7 Professional and am a local administrator.

Edit:
After Richard’s suggestion, I tried the verbose mode (which seemed to have no effect).

PS Z:\> $error[0] | fl * -force

PSMessageDetails      : 
Exception             : System.IO.IOException: Not Enough permission to perform operation.
TargetObject          : D:\path\file.txt
CategoryInfo          : PermissionDenied: (D:\path\file.txt:FileInfo) [Remove-Item], IOException
FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
ErrorDetails          : Cannot remove item D:\path\file.txt: Not Enough permission to perform operation.
InvocationInfo        : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 1}

I don’t see anything of much use there (but thanks for the tips anyway).

Edit 2:
Okay, here’s the script source:

remove-item D:\path_A\* -recurse
copy-item D:\path_B\* D:\path_A\

That’s it. The remove-item seems to throw at every file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:09:17+00:00Added an answer on May 26, 2026 at 7:09 am

    Is UAC enabled? If so try running your PowerShell session as ‘Administrator’. It really looks like you don’t have permission to delete the objects.

    We have very restrictive security policies where I work and users not familiar with UAC get burned all the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a PowerShell script that will do the following: Executes a
I am trying to write a PowerShell script to replace the contents of tags
I am trying to write a powershell script that will set a download directory
I am trying to create a PowerShell script that creates a new IIS 6
I'm trying to write a small Powershell function that will return some summary data
Little new to powershell. I am trying to locate a get-childitem like command that
I'm relatively new to PowerShell, and I was trying to copy files using a
I'm new to powershell and this question will prove that point. I'm trying a
I am trying to use WPF printing from PowerShell. I have found a simple
I am trying to write a powershell script for Exchange Management Shell, importing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.