Kaseya Community

executePowershell doesn't work but i don't see an error either

  • Hi,

    I am trying to execute a simple one line powershell command and i am using ececutePowershell in the scripting area.

    The command is Invoke-RestMethod -Uri "https://api.telegram.org/.............")/sendMessage?chat_id=$(...........)&text=$("Test message")"

    Offcourse i removed the unique tokens and replaced them with ............

    Does someone has a clue why the script runs without error, but i don't get a message trough the API. When i paste the exact command in a powershell window, it does work.

  • As an addition, or maybe someone else has a better idea to execute this script when a server reboots? I would like to receive a message in my Telegram Bot when a servers comes online.

  • I believe if you are running the script as local system you won’t have internet access. Try setting a credential on the machine and using Use Credential in the proc.
  • Tried Use credentials and added credentials to the appropiate machine ID, but that doesn't work and tried impersonateUser but that doesn't work either or i am doing something wrong.

  • I use an alternate scripting language, but all of the API calls that I make are while the script is running in SYSTEM mode. Local System doesn't have NetBIOS access without providing credentials, but I make curl, wget, and API calls across the Internets all the time.

    Just for kicks - try creating a PS script file to invoke. I've had the dumbest things not work when called directly but work fine in a Bat file from a executeShellCommand call.

    Glenn

  • Have you tried executing that oneliner using executePowerShell32/64BitSystem command? I think executePowershell() is still broken.