$ErrorActionPreference = "Stop" $pass = ConvertTo-SecureString ("Paper123" + [char]33 + "@#") -AsPlainText -Force $cred = New-Object PSCredential("INTRANET\sysadmin", $pass) $uncRoot = "\\192.168.0.6\C$" try { New-PSDrive -Name AD2 -PSProvider FileSystem -Root $uncRoot -Credential $cred -ErrorAction Stop | Out-Null Write-Output "=== DRIVE MAPPED ===" $scriptPath = "AD2:\Shares\test\scripts\Sync-FromNAS.ps1" $content = Get-Content $scriptPath -Raw # Show the original problematic lines Write-Output "=== ORIGINAL Copy-FromNAS SCP LINE ===" $content -split "`n" | Where-Object { $_ -match "SCP.*RemotePath.*LocalPath|SCP.*LocalPath.*RemotePath" } | ForEach-Object { Write-Output $_.Trim() } Write-Output "=== ORIGINAL Invoke-NASCommand LINE ===" $content -split "`n" | Where-Object { $_ -match "result = .* \" } | ForEach-Object { Write-Output $_.Trim() } Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue } catch { Write-Output "ERROR: $_" }