How to keep the file on desktop up to date?

Andy 51 Reputation points
2022-01-29T03:35:47.343+00:00

Question
We want to push file from shared folder to user's desktop

e.g Copy file ABC.pdf to C:\user\public\Desktop from \shared\ABC.pdf

If I changed the content in ABC.pdf how Can I make sure on the user's desktop also updated?(Same version with shared one)
We can't change the name ABC.pdf

Any script can achieve it? PowerShell or Batch or deploy via MECM/SCCM

Thanks

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,085 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. chao wang 1 Reputation point
    2022-01-29T05:24:32.437+00:00

    I think you could use Powershell

    1. user a logon scripts
    2. use Test-path , to make sure the ABC.pdf does it exist on desktop
    3. use Compare-Object, to Compare files $objects = @{
      ReferenceObject = (Get-ChildItem -Path "xx.txt")
      DifferenceObject = (Get-ChildItem -Path "xx.txt")
      }
      Compare-Object @objects -Property LastWriteTime -ExcludeDifferent

  2. chao wang 1 Reputation point
    2022-01-29T07:49:55.947+00:00
    if(Boolean_expression) {
       // Executes when the Boolean expression is true
    }else {
         // Executes when the Boolean expression is false
       if()....
    
    }
    
    0 comments No comments

  3. Andy 51 Reputation points
    2022-01-29T08:55:46.877+00:00

    $fileA = "C:\Users\Public\Desktop\ABC.pdf"
    $fileB = "\shared\ABC.pdf"

    if(Test-Path $fileA)
    {
    if((Get-FileHash $fileA).hash -eq (Get-FileHash $fileB).hash)
    {
    Write-host : 'Files are the same and update to date'
    Break
    }

    if((Get-FileHash $fileA).hash -ne (Get-FileHash $fileB).hash)
    {
    Write-host :'File need update'}
    }
    }
    else
    {
    Write-host :'File Copied and update to date'
    }

    I found the solution

    Works like a charm!

    0 comments No comments