Quantcast
Viewing all articles
Browse latest Browse all 1056

Batch Files / .VBS / Powershell Scripts work locally but not in an Ivanti Distribution Package

Description

   In some environments. You might run into an issue where you can run a script locally just fine but when you try to push the script out in a package, EPM shows the the script was launched but nothing happens.

   Some script actions and .vbs scripts will not execute if they are under C:\Program files, C:\Program Files(X86) or Remote execution. This behavior applies to both windows 7 and 10. You can also set the task to "Run from source" under The task settings. Most of the time this will get around the permissions issues in windows. However, there are still some actions that do not work remotely in which case the steps below have proven helpful.

 

Solution

Copying the script to C:\windows\temp, then executing from there.

 

  • Go to Tools > Distribution > Distribution Packages.
  • Create a new windows action package.
  • Add a custom action. This will move the file into C:windows\temp
<#
Move a file
#>

Move-Item "C:\<PathtoFileinSDMcache>" "C:\windows\temp\Filename" -force

if ($? -ne $true)
{
    exit 1
}

 

  • Create another custom action. For .ps1 or VBS you will need to use:
Set-location "C:\windows\temp";
Powershell.exe -execution bypass -nologo -file .\PS1 or .\VBS

if ($? -ne $true)
{
    exit 1
}

 

 

For Batch files you can use:

$A = Start-Process -FilePath "C:\Windows\temp\movefile.bat" -WindowStyle Hidden -Wait -passthru;$a.ExitCode

 

Add the file listed in step 3 as an additional file.

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 1056

Trending Articles