$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 Write-Output "=== DRIVE MAPPED ===" $scriptPath = "AD2:\Shares\test\scripts\Sync-FromNAS.ps1" if (Test-Path $scriptPath) { Write-Output "=== SCRIPT CONTENT START ===" Get-Content $scriptPath -Raw Write-Output "=== SCRIPT CONTENT END ===" } else { Write-Output "Script not found" } Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue } catch { Write-Output "ERROR: $_" }