Deployment Solution

 View Only
  • 1.  How do I run PowerShell from the "Run this script" field in DS 6.9?

    Posted May 30, 2012 12:22 PM

    We're running DS 6.9 SP5 MR2, so PowerShell is natively supported. In a DS "Run Script" task, you can either run the script by selecting the script file or entering the script in the "Run this script" field. The only thing that works for me in the "Run this script" field is bat/cmd files. In this

    https://www-secure.symantec.com/connect/forums/what-s-new-deployment-server-69-sp5-mr2-and-pc-transplant-68-sp4-mr2

    connect posting, someone comments

    For Run Script Dialog the user will have to use comment # Powershell somewhere in the script which is pretty similar to how VB Scripts that need to have the comment 'vbscript in them.

    This doesn't work for me. As far as I can tell, the lines in the "Run this script" field are always parsed by CMD.EXE. Is PowerShell or VBS even supported in this field? It would be pretty cool to have a little section with "Choose the script parser: PowerShell.exe / cmd.exe / cscript.exe" with a radio button next to each.

    It's annoying to have a job full of Run Script tasks with identical descriptions: "F:\Program Files(x86)\Altiris\eX..."

     



  • 2.  RE: How do I run PowerShell from the "Run this script" field in DS 6.9?

    Posted May 30, 2012 05:43 PM

    Yes the (few other) other Script-Languages are supported as well.

    Per default the script will be parsed by the Command Prompt.

     

    But when you start your Script in this field with the first line:

    'vbscript

    It will be parsed by CSCRIPT.

    And i assume that you need to start like this as well for PowerShell:

    #Powershell

    To run your PowerShell Script.

     

     

    Regards,

    tester2k5



  • 3.  RE: How do I run PowerShell from the "Run this script" field in DS 6.9?
    Best Answer

    Posted Jun 01, 2012 02:01 AM

    Please try below steps.........

    1. Make sure that executionpolicy is set to unrestricted on client side which enables powershell script execution on client machine. Or Execute command “set-executionpolicy  unrestricted “ on client machine before executing powershell scripts through DS runscript task.

    2.On Win32 console, Create a new "Run Script" job
    3.Type the below powershell script in 'Run this script:" dialog
    #powershell
    2 + 2 >> C:\test.txt 

    4.Schedule this job on a client machine.
    5. test.txt file should get created on client machine with 4 as output

    Thanks

     

     



  • 4.  RE: How do I run PowerShell from the "Run this script" field in DS 6.9?

    Posted Jun 05, 2012 12:40 PM

    The "p" in "#powershell" must be lower-case in order for it to work. I was using an upper-case "P".



  • 5.  RE: How do I run PowerShell from the "Run this script" field in DS 6.9?

    Posted Jun 05, 2012 12:42 PM

    Yeah, 'vbscript did work for me. Dunno what I was doing wrong before. Thanks. #powershell must be all lowercase in order for the DS to send it to PowerShell.