PDQ Deploy Injecting code into Powershell script

Comments

7 comments

  • Stephen Valdinger

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

    0
    Comment actions Permalink
  • Max Williams

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

    0
    Comment actions Permalink
  • Daniel Wahlfridsson

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

    https://i.imgur.com/YRxVr8E.png

    aao works :)

    https://i.imgur.com/zGEl64Z.png

     

    0
    Comment actions Permalink
  • Max Williams

    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"}

    0
    Comment actions Permalink
  • Max Williams

    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!

    0
    Comment actions Permalink
  • Stephen Valdinger

    $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. 

    0
    Comment actions Permalink
  • Stephen Valdinger

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

    0
    Comment actions Permalink

Please sign in to leave a comment.