Variable $LastDP i set within a script loses its value while deploying through SCCM . I have tested this script in SYSTEM context using psexec -i -s cmd.exe and it works but it seems to return null value via SCCM. Also tried to set variable scope as global but it didn't work. It inserts $laspDp value when get to this part "$config1 | % { $_.Replace("\server", "\$LastDP\SMSPKGE$\C02076B8\SA") } | Set-Content .\Configuration.Project.mvp1.v001_cdnSA.xml" when ran it as an admin in ISE and also when ran script in SYSTEM context which i believe SCCM use too. when ran through CM/software center it loose the $lastDp value and the entry in xml file is "\\SMSPKGE$\C02076B8\SA". Command line to run the script
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -Noprofile -file "%currentdir%\script.ps1