Needs to check last error after invoking renam-item, because it can fail, eg if a renamed directory is open in another application and therefore locked, the rename operation will fail. Currently, rename-FsItem does not check the last error code and assumes the rename proceeds without error and returns $null implicily via a call to Get-Item on the intended destination path.
The last error description can be accessed via $error[0] and an Exception needs to be thrown that includes the error denoted in $error[0].
If the folder is currently open in another app, like an explorer, the error will be access denied.
Actually, the fix is simpler than this. rename-FsItem should not be catching exceptions and should let Rename-Many handle the exception.
discovered a slight apprently inconsequential error in use-actionParams, there is some use of the variable $_exchange which is declared in the parent scope. Should be using the local version passed $exchange.
Needs to check last error after invoking renam-item, because it can fail, eg if a renamed directory is open in another application and therefore locked, the rename operation will fail. Currently, rename-FsItem does not check the last error code and assumes the rename proceeds without error and returns $null implicily via a call to Get-Item on the intended destination path.
The last error description can be accessed via $error[0] and an Exception needs to be thrown that includes the error denoted in $error[0].
If the folder is currently open in another app, like an explorer, the error will be access denied.
Actually, the fix is simpler than this. rename-FsItem should not be catching exceptions and should let Rename-Many handle the exception.