Comparing folders and content with PowerShell

后端 未结 6 1472
广开言路
广开言路 2020-12-02 17:43

I have two different folders with xml files. One folder (folder2) contains updated and new xml files compared to the other (folder1). I need to know which files in folder2 a

6条回答
  •  猫巷女王i
    2020-12-02 18:13

    Handy version using script parameter

    Simple file-level comparasion

    Call it like PS > .\DirDiff.ps1 -a .\Old\ -b .\New\

    Param(
      [string]$a,
      [string]$b
    )
    
    $fsa = Get-ChildItem -Recurse -path $a
    $fsb = Get-ChildItem -Recurse -path $b
    Compare-Object -Referenceobject $fsa -DifferenceObject $fsb
    

    Possible output:

    InputObject                  SideIndicator
    -----------                  -------------
    appsettings.Development.json <=
    appsettings.Testing.json     <=
    Server.pdb                   =>
    ServerClientLibrary.pdb      =>
    

提交回复
热议问题