$pass = ConvertTo-SecureString ("Paper123" + [char]33 + "@#") -AsPlainText -Force $cred = New-Object PSCredential("INTRANET\sysadmin", $pass) $uncPath = "\\192.168.0.6\C$\Shares\test\scripts" # Map net use net use "\\192.168.0.6\C$" /user:INTRANET\sysadmin ("Paper123" + [char]33 + "@#") 2>&1 | Out-Null # Write the bulk sync script using direct UNC path $bulkContent = @" Set-Location "C:\Shares\test\scripts" & powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Shares\test\scripts\Sync-FromNAS.ps1" -MaxAgeMinutes 86400 -Verbose "@ [System.IO.File]::WriteAllText("\\192.168.0.6\C$\Shares\test\scripts\BulkSync-OneTime.ps1", $bulkContent) Write-Output "[OK] BulkSync script written via System.IO" # Verify it exists $exists = Test-Path "\\192.168.0.6\C$\Shares\test\scripts\BulkSync-OneTime.ps1" Write-Output "File exists: $exists" # Now trigger it via WMI $proc = Invoke-WmiMethod -ComputerName 192.168.0.6 -Credential $cred -Class Win32_Process -Name Create -ArgumentList "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Shares\test\scripts\BulkSync-OneTime.ps1" if ($proc.ReturnValue -eq 0) { Write-Output "[OK] Bulk sync started on AD2\! PID: $($proc.ProcessId)" } else { Write-Output "[ERROR] Failed to start: return value $($proc.ReturnValue)" } net use "\\192.168.0.6\C$" /delete 2>&1 | Out-Null