Important Notice: On February 29th, this community will be put into read-only mode. All existing posts will remain but customers will be unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

PDQ Deploy Injecting code into Powershell script

I am trying to push a Powershell script in PDQ Deploy but when I run it on a remote computer it errors off talking about this "@chcp 65001>nul". It looks to be code related to setting language but it was not in my script so found in the output log that is shows the path to the script that was ran and made a copy of it before PDQ deleted it out of the local system after it fails.

I opened the script a found all my code was in there but in addition to my code the very top line had "@chcp 65001>nul". I am sure there is a good reason for putting this code ahead of my script but it is failing do to it being there. Does anyone know why it is there and how worse case do I tell PDQ Deploy to not inject addition code into my script?



Date Votes
  • Are you using a Powershell Step, or actually pushing a ps1 file?

  • I am using the Powershell step and just pasting in the code.

  • I tried using å ä ö in my powershell script and got the same error message.

    aao works :)


  • So there is a character from another language in there? That would explain it but it a normal script with standard English characters. I will have to do some digging into what is setting it off then. Here is the script I am using if anyone can point out where I went wrong:

    # Get Operating System Info
    $OS = (Get-WmiObject Win32_OperatingSystem).name

    # Enable .Net 3.5 based off what version of Windows is running
    if ($OS -like "*Server 2012 R2*")
    {Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All -LimitAccess -Source "\\servername\Repository\Microsoft\.Net 3.5 - Server 2012R2\sources\sxs"}
    ElseIf ($OS -like "*Windows 10*")
    {Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All -LimitAccess -Source "\\servername\Repository\Microsoft\.Net 3.5 - Windows 10\sources\sxs"}

  • Okay it was the dashes, must have got them from copying the command off some site. It is working now, thanks for the help Daniel!

  • $OS = (Get-WmiObject Win32_OperatingSystem).name

    If($os -like "*Server 2012 R2*"){

    Write-Host "Server 2012 OS"


    Elseif($os -like "*Windows 8*"){

    Write-Host "Windows 8.1"



    This yields Window 8.1 written to the host when I run it. Your code looks fine. 

    This is pretty curious. 

  • I bet it came off the web as unicode. That makes perfect sense then. Glad you got it figured out.


Please sign in to leave a comment.

Didn't find what you were looking for?

New post