0

I have created a Powershell script which uses the Active Directory Module. I need to execute the script from a 3rd party application called LANDesk.

When I do that it doesn't run the script properly. I believe it's because of the AD Module. When I run the script in the Powershell prompt with the AD Module loaded it works fine.

durron597
  • 31,968
  • 17
  • 99
  • 158
Bobby
  • 57
  • 1
  • 3
  • 6

2 Answers2

1

From an application like that you should be able to run it like so:

powershell.exe -file c:\myscript.ps1

If the app is trying to run the script from the context of another user you may need to make sure that the user has run Set-ExecutionPolicy RemoteSigned (or Unrestricted). Another possibility is that your script works running under a 32-bit PowerShell prompt and the app is launching the 64-bit version of PowerShell (or vice-versa).

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
0

Call powershell from your application and pass the script path to the File parameter. Inside the script, import the AD module and then add the commands that relu on the AD module. If necessary, you can set the execution policy via the ExecutionPolicy parameter.

Shay Levy
  • 121,444
  • 32
  • 184
  • 206