$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password) Write-Host "================================================" -ForegroundColor Cyan Write-Host "Checking BAT files on AD2" -ForegroundColor Cyan Write-Host "================================================" -ForegroundColor Cyan Write-Host "" Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock { Write-Host "=== Root Files ===" -ForegroundColor Yellow Get-ChildItem C:\Shares\test\*.BAT -ErrorAction SilentlyContinue | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize Write-Host "=== COMMON\ProdSW ===" -ForegroundColor Yellow Get-ChildItem C:\Shares\test\COMMON\ProdSW\*.BAT -ErrorAction SilentlyContinue | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize Write-Host "=== _COMMON\ProdSW ===" -ForegroundColor Yellow Get-ChildItem "C:\Shares\test\_COMMON\ProdSW\*.BAT" -ErrorAction SilentlyContinue | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize }