-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I have a solution that may resolve this, but here is the issue first from a test run:
PS C:\working_directory\Documents> Start-PsFCIV -Path .\ -XML "C:\working_directory\DB.xml" -HashAlgorithm SHA256 -Recur
se -Verbose -Debug -Action Rename
DEBUG: Native PsFCIV mode ON
VERBOSE: Perform file 'Directory1\Another Test File.txt' checking.
DEBUG: Selected hash name : SHA256
DEBUG: Selected hash value: 6978413F9D61E2AA69A31CB7750B80B7FFF5C9F9DF5336A1D0612EFB6C54A58A
DEBUG: File hash: 6978413F9D61E2AA69A31CB7750B80B7FFF5C9F9DF5336A1D0612EFB6C54A58A
VERBOSE: File 'Another Test File.txt' is ok.
VERBOSE: Perform file 'a text file.txt' checking.
DEBUG: Selected hash name : SHA256
DEBUG: Selected hash value: 837CCB607E312B170FAC7383D7CCFD61FA5072793F19A25E75FBACB56539B86B
DEBUG: File hash: 837CCB607E312B170FAC7383D7CCFD61FA5072793F19A25E75FBACB56539B86B
VERBOSE: File 'a text file.txt' is ok.
VERBOSE: Perform file '[Torgo].gif' checking.
DEBUG: Selected hash name : SHA256
DEBUG: Selected hash value: 0201C1264D23B9EA3183CF5AFA953CA470A3A786F79B039C84C0AB05FEF171AC
DEBUG: File '[Torgo].gif' failed hash verification.
Expected hash: @{HashName=System.String[];
HashValue=0201C1264D23B9EA3183CF5AFA953CA470A3A786F79B039C84C0AB05FEF171AC}.HashValue
Actual hash: 7C462C54798E9CA1A737A91E7F4B120460EF8754D00B7F7A1FFE09F395F1AFBC
Rename-Item : Cannot rename because item at 'C:\working_directory\Documents\[Torgo].gif' does not exist.
At C:\Program Files\WindowsPowerShell\Modules\PsFCIV\1.1\PsFCIV.psm1:95 char:19
+ "Rename" {Rename-Item $file $($file.FullName + ".bad")}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand
-----------------------------------
Total files processed : 3
Total good files : 2
Total bad files : 1
Total unknown status files : 0
Total missing files : 0
Total locked files : 0
-----------------------------------
Total : 3
New : 0
Ok : 2
Bad : 1
Missed : 0
Locked : 0
Unknown : 0
Deleted : 0
It would seem that both the Rename-Item and Remove-Item cmdlets require the -LiteralPath paramenter to be able to interpret square brackets or other special characters.
I would suggest modifying this function:
Line 92 in dbc00cf
| # process -Action parameter to perform an action against bad file (if actual file properties do not match the record in XML). |
possible changes below. I have also included two calls to Write-Verbose since I feel better knowing when a file is being modified.
# process -Action parameter to perform an action against bad file (if actual file properties do not match the record in XML).
function __takeAction ($file, $Action) {
switch ($Action) {
"Rename" {
Write-Verbose "Action: Rename file '$file' to '$($file.FullName + ".bad")'"
Rename-Item -LiteralPath $file -NewName $($file.FullName + ".bad")
}
"Delete" {
Write-Verbose "Action: Delete file '$file'"
Remove-Item -LiteralPath $file -Force
}
}
}
Would it be possible to push version 1.2 to the powershell gallery later? It makes managing versions and re-deployment a bit easier. Thank You!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels