$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 Write-Output "=== FULL VERIFICATION: Lines 48-100 ===" for ($i = 47; $i -lt 100 -and $i -lt $lines.Count; $i++) { Write-Output ("{0,3}: {1}" -f ($i+1), $lines[$i]) } # Also check the script parses without errors Write-Output "" Write-Output "=== SYNTAX CHECK ===" $parseErrors = $null [System.Management.Automation.Language.Parser]::ParseFile("AD2:\Shares\test\scripts\Sync-FromNAS.ps1", [ref]$null, [ref]$parseErrors) if ($parseErrors.Count -eq 0) { Write-Output "Script parses OK - no syntax errors" } else { foreach ($err in $parseErrors) { Write-Output "PARSE ERROR: $($err.Message) at line $($err.Extent.StartLineNumber)" } } Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue } catch { Write-Output "ERROR: $_" }