$pass = ConvertTo-SecureString ("Paper123" + [char]33 + "@#") -AsPlainText -Force $cred = New-Object PSCredential("INTRANET\sysadmin", $pass) # Check if still running $procs = Get-WmiObject -ComputerName 192.168.0.6 -Credential $cred -Class Win32_Process -Filter "Name='powershell.exe'" 2>$null $syncRunning = $false foreach ($p in $procs) { if ($p.CommandLine -match "BulkSync|86400") { Write-Output "Still running: PID=$($p.ProcessId)" $syncRunning = $true } } if (-not $syncRunning) { Write-Output "Bulk sync has completed\!" }