# Check AD2 sync log to verify NAS sync status

$Username = "INTRANET\sysadmin"
$Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential($Username, $Password)

Write-Host "[INFO] Connecting to AD2 to check sync log..."

try {
    $LogContent = Invoke-Command -ComputerName 192.168.0.6 -Credential $Cred -ScriptBlock {
        Get-Content 'C:\Shares\test\scripts\sync-from-nas.log' -Tail 30
    }

    Write-Host "[OK] Sync log retrieved:"
    Write-Host ""
    $LogContent | ForEach-Object { Write-Host $_ }

} catch {
    Write-Host "[ERROR] Failed to connect to AD2: $_"
}
