Powershell script in package; Windows Desktop

Powershell script in package; Windows Desktop

Device: Windows Desktop

Goal: create directory file list (text file) POST copy routine

Summary:

- Package contains N number of files to be copied to a specific folder

- Prescript creates file list BEFORE copy (via Powershell)

- Postscript creates file list AFTER copy (via Powershell)

  • Syntax: start powershell.exe c:\temp\DirPost.ps1
  • Powershell scripts are located in c:\temp directory

 

I'm not able to get Powershell to run.  I can call it via the script window without issue but it fails to run via the package postscript.  I've considered using "shellexecute" but SOTI doesn't provide a list of "VERBS".

---- extract from SOTI Help file ----

shellexecute filepath -verb [-wseconds]

Where

  • -verb is the action you want the shell to execute
  • -w tells the command to wait for the specified length of time (in seconds) before executing

---------------------------------------

 

 

 

5 Answers

Order By:   Standard | Newest | Votes
SMod@Soti | posted this 28 August 2018

Hi Shawn,

 

The command shellexecute is used to launch a registered app for a specific File extension as follows:

shellexecute

Launches the registered application for the given file extension.

Syntax:

shellexecute <filepath> <-verb> [-w<seconds>]

To launch the registered application for the given file extension:

shellexecute 1:\temp\temp.upg -open

shellexecute 1:\temp\temp.upg -run -w5

 

Can you please try to include the following script in the package to open a ps1 file:

powershell -noexit "& ""C:\temp\DirPost.ps1"""

Please let me know if you have any questions.

 

Thanks

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Shawn, Wilkerson | posted this 28 August 2018
Using "start" or "shellexecute"?

powershell
-noexit "& ""C:\temp\DirPost.ps1"""
  • 0
  • 0
SMod@Soti | posted this 28 August 2018

Use the script:

powershell -noexit "& ""C:\temp\DirPost.ps1"""

This script will execute the powershell file specified in the path.

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Shawn, Wilkerson | posted this 29 August 2018

Unfortunately that didn't work. If I run the script from the Remote Control shell window it works if I remove 1 set of quotes, but it doesn't work from within the posti.cmd. 

  • 0
  • 0
SMod@Soti | posted this 29 August 2018

Hey Shawn,

 

Can you please try the following script in the post-install script for your package and see if it executes the ps1 file:

 

start C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe C:\temp\DirPost.ps1

 

For some reason, if you specify just powershell.exe, MobiControl agent looks for powershell.exe in the agent folder.

 

Please let me know if it works.

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0

Give us your feedback
Give us your feedback
Feedback