Client Management Suite

 View Only
  • 1.  Running Powershell Scripts

    Posted Jul 20, 2016 09:33 AM

    I'm just wondering if anybody has best practices for running Powershell scripts as tasks or softwar deliveries. I'd like to send basic scripts to do things like removing directories that are no longer used or shortcuts with dead links. I've tried running it with just the script name as the command line, i.e., "script.ps1." I've also tried running it with <powershell.exe -windowstyle hidden "script.ps1"> as well as creating a batch file to write the same command, and running that instead. None of these work for me.



  • 2.  RE: Running Powershell Scripts

    Posted Jul 20, 2016 03:06 PM

    We have a lot of PS script. Create a new task\Run Script

    In the "script type" drop down select PowerShell and paste your script in the body.

    Done.



  • 3.  RE: Running Powershell Scripts

    Posted Jul 20, 2016 10:53 PM

    We do the same thing as Michael Farber. The only thing you need to make sure of before that option works is that your execution policy is set properly or your scripts are signed.



  • 4.  RE: Running Powershell Scripts
    Best Answer

    Posted Jul 21, 2016 10:59 AM


  • 5.  RE: Running Powershell Scripts

    Posted Aug 03, 2016 08:26 AM

    You need to change the excecution policy first for Powershell. You can do locally on pc for example. set-executionpolicy -ExecutionPolicy remotesigned. Then you just create a PS task in Altiris. It will execute it according to the policy.I've done globally via GPO.

    If you run the script as parameter from the command line, you can specify the execution policy at runtime.

    For example:powershell -ExecutionPolicy ByPass -File C:\myscript.ps1. It will run regardless of the pc's execution policy.

    At https://powershell.org/ you can ask any powershell related questions.