Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell - Rename-item returning "Access to the path pathname is denied"

$
0
0

Hi Guys,

There are a few hits with this error relating to this error, but I have yet to find one that resolves the error.

Most of the problems have been UAC or the user doesn't have permissions etc.

I am pretty sure I have covered these off, but I am still getting the error.

Rename-Item -path "\\servername\scratch\0_THIS_WEEK" -newName "\\servername\scratch\1_LAST_WEEK" -ErrorAction Stop
Rename-Item : Access to the path '\\servername\scratch\0_THIS_WEEK' is denied.
At line:1 char:1
+ Rename-Item -path "\\servername\scratch\0_THIS_WEEK" -newName "\\servername\scratch\1_LAST ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (\\servername\scratch\0_THIS_WEEK:String) [Rename-Item], IOException

    + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand

I can not rename manually as a domain admin (who is also a local admin) and running as administrator.

The new path does not already exist.

I have confirmed (with effective access) that I have full control of this directory.

I have got the verbose logging for the error...

$error[0] | fl * -force
ErrorRecord                 : Access to the path '\\servername\scratch\0_THIS_WEEK' is denied.
StackTrace                  :   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate (Object input, Hashtable errorResults, Boolean enumerate)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                                at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                                at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message                     : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Access to the path '\\servername\scratch\0_THIS_WEEK' is denied.
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              :
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087

Domain users have read rights to the top level of the share and read and write rights on the 0_THIS_WEEK directory.  I have tried removing the R/W rights on 0_THIS_WEEK in case there are file locks but this hasn't helped.

Is there a way to find out what is preventing the rename (ie file locks) so I can either disconnect this session or release the lock?

NB:  I have also tried using d:\scratch\0_THIS_WEEK rather than the share name with the same results.

Thanks

Glenn



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>