$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password) Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock { Write-Host "=== Files in _COMMON\ProdSW ===" -ForegroundColor Yellow Get-ChildItem "C:\Shares\test\_COMMON\ProdSW" -File | Select-Object Name, Length, LastWriteTime | Sort-Object Name | Format-Table -AutoSize Write-Host "" Write-Host "=== Files in COMMON\ProdSW ===" -ForegroundColor Yellow Get-ChildItem "C:\Shares\test\COMMON\ProdSW" -File | Select-Object Name, Length, LastWriteTime | Sort-Object Name | Format-Table -AutoSize Write-Host "" Write-Host "=== Files ONLY in _COMMON\ProdSW ===" -ForegroundColor Cyan $underFiles = Get-ChildItem "C:\Shares\test\_COMMON\ProdSW" -File | Select-Object -ExpandProperty Name $commonFiles = Get-ChildItem "C:\Shares\test\COMMON\ProdSW" -File | Select-Object -ExpandProperty Name $onlyInUnder = $underFiles | Where-Object { $_ -notin $commonFiles } if ($onlyInUnder) { $onlyInUnder | ForEach-Object { Write-Host " $_" -ForegroundColor White } } else { Write-Host " (none)" -ForegroundColor Gray } Write-Host "" Write-Host "=== Files ONLY in COMMON\ProdSW ===" -ForegroundColor Cyan $onlyInCommon = $commonFiles | Where-Object { $_ -notin $underFiles } if ($onlyInCommon) { $onlyInCommon | ForEach-Object { Write-Host " $_" -ForegroundColor White } } else { Write-Host " (none)" -ForegroundColor Gray } }