Skip to content

New-FileCatalog ignores -WhatIf #2866

Closed

Description

@PatrickFB

Steps to reproduce

C:\PS> Get-Date > Date.tmp
C:\PS> New-FileCatalog -CatalogVersion 2 -CatalogFilePath catalog.cat -Path Date.tmp -WhatIf

Expected behavior

What if: Performing the operation "Create new file catalog" on target "C:\PS\catalog.cat".

Actual behavior

Mode          LastWriteTime Length Name       
----          ------------- ------ ----       
-a----  12/9/2016  12:37 PM    433 catalog.cat

You can see the file has been created.
The Hash is also being calculated too.

C:\PS> Test-FileCatalog -Detailed -CatalogFilePath catalog.cat 

Status        : Valid
HashAlgorithm : SHA256
CatalogItems  : {[Date.tmp, 2F38E0FD77AF90E6E463938C4D4ED9AE03F575AC7C0441C6A3DBE9A1C4D55459]}
PathItems     : {[Date.tmp, 2F38E0FD77AF90E6E463938C4D4ED9AE03F575AC7C0441C6A3DBE9A1C4D55459]}
Signature     : System.Management.Automation.Signature

C:\PS> Get-FileHash -Path Date.tmp

Algorithm : SHA256
Hash      : 2F38E0FD77AF90E6E463938C4D4ED9AE03F575AC7C0441C6A3DBE9A1C4D55459
Path      : C:\Temp\Demo\Date.tmp

Environment data

> $PSVersionTable

Name                      Value                  
----                      -----                  
PSVersion                 5.1.14393.206          
PSEdition                 Desktop                
PSCompatibleVersions      {1.0, 2.0, 3.0, 4.0...}
BuildVersion              10.0.14393.206         
CLRVersion                4.0.30319.42000        
WSManStackVersion         3.0                    
PSRemotingProtocolVersion 2.3                    
SerializationVersion      1.1.0.1                

Activity

  1. iSazonov commented on Dec 9, 2016

    @iSazonov
    Collaborator

    PatrickFB Could you make the test with the latest build Powershell 6.0?

  2. kittholland commented on Dec 9, 2016

    @kittholland
    Contributor

    I was able to reproduce based on his steps.

    Name                           Value
    ----                           -----
    BuildVersion                   3.0.0.0
    PSVersion                      6.0.0-alpha
    CLRVersion
    GitCommitId                    v6.0.0-alpha.13-37-gbbf1766ac7e82d301346e477dcab85721395be1d
    PSEdition                      Core
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    PSRemotingProtocolVersion      2.3
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    
    PS C:\temp\catalogtest> get-date | Out-File date.tmp
    PS C:\temp\catalogtest> New-FileCatalog -CatalogVersion 2 -CatalogFilePath catalog.cat -Path Date.tmp -WhatIf
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        12/9/2016   2:28 PM            433 catalog.cat
    
    
    PS C:\temp\catalogtest>  Test-FileCatalog -Detailed -CatalogFilePath catalog.cat
    
    
    Status        : Valid
    HashAlgorithm : SHA256
    CatalogItems  : {[Date.tmp, 9DC50C439A67C3C563925DAA3BB8B1C732D990DC9D798E0FED02F102114CAA50]}
    PathItems     : {[date.tmp, 9DC50C439A67C3C563925DAA3BB8B1C732D990DC9D798E0FED02F102114CAA50]}
    Signature     : System.Management.Automation.Signature
    
  3. added
    Issue-Enhancement
    Up-for-Grabs
    Hacktoberfest
    on Oct 31, 2018
  4. MarekZietek commented on Feb 24, 2019

    @MarekZietek

    if (ShouldProcess(catalogFilePath))
    {
    PerformAction(paths, catalogFilePath);
    }

    There already exists a call to ShouldProcess in CatalogCommands.cs. Apparently the reason that it doesn't work is that it calls the 1-parameter function and not the 2-parameter one. This is weird because both methods should do the same thing but they don't. Adding a second parameter action fixes it.

    Is this expected behavior for the single parameter method to return true when what if is specified?

  5. iSazonov commented on Feb 25, 2019

    @iSazonov
    Collaborator

    No repo is in 6.2 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestIssue-EnhancementResolution-FixedUp-for-GrabsWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions