$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 $scriptPath = "AD2:\Shares\test\scripts\Sync-FromNAS.ps1" $lines = Get-Content $scriptPath # Show lines 70-95 (around Copy-FromNAS SCP area) Write-Output "=== Lines 60-95 ===" for ($i = 59; $i -lt 95 -and $i -lt $lines.Count; $i++) { Write-Output ("{0,3}: {1}" -f ($i+1), $lines[$i]) } Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue } catch { Write-Output "ERROR: $_" }