# Verify line endings on AD2 and copy fresh to NAS $Username = "INTRANET\sysadmin" $Password = ConvertTo-SecureString "Paper123!@#" -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential($Username, $Password) Write-Host "[INFO] Connecting to AD2..." New-PSDrive -Name TEMP_AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $Cred -ErrorAction Stop | Out-Null Write-Host "[INFO] Reading DEPLOY.BAT from AD2..." $Content = Get-Content "TEMP_AD2:\Shares\test\DEPLOY.BAT" -Raw if ($Content -match "`r`n") { Write-Host "[OK] AD2 file has CRLF line endings" # Copy to temp location Copy-Item "TEMP_AD2:\Shares\test\DEPLOY.BAT" ".\DEPLOY_FROM_AD2.BAT" -Force Write-Host "[OK] Copied DEPLOY.BAT from AD2 to local temp" } else { Write-Host "[ERROR] AD2 file has wrong line endings!" } Remove-PSDrive TEMP_AD2 # Now check local file Write-Host "" Write-Host "[INFO] Verifying local copy..." $result = & cmd /c "type DEPLOY_FROM_AD2.BAT | find /c `"@ECHO`"" Write-Host "[OK] Local file readable"