Jump to content
ATrotter

Powershell popup not displaying

Recommended Posts

Hi all.

Im having a little trouble getting a scrip to work.

I have tried a few different options to get it all working, however nothing comes up.
so far i have tried.
condensing the script and just calling it in a script.
creating a script file and dumping it on the client machine and then calling it.

the script work pefectly if i just run it on the computer, but the second automate is involved. nothing.

 

the script is below for anyone interested

 

-windowstyle hidden
Add-Type -AssemblyName PresentationCore,PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::Ok
$MessageIcon = [System.Windows.MessageBoxImage]::Exclamation
$MessageBody = "This computer will reboot overnight. 
if you have any questions or concerns call "
$MessageTitle = "Computer will reboot"
$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)

Share this post


Link to post
Share on other sites

Which script function in Automate are you using to call the powershell code? It is likely the script is running as the "SYSTEM" user and not the currently logged in console user. When running as SYSTEM, popups won't be displayed on the Desktop. 

Gavsto has a nice write up on how to run scripts in the context of the currently logged on user. Running Scripts as Logged In User

Share this post


Link to post
Share on other sites

Methods i have tried so far.

 

Powershell command as Admin/Powershell command(bothways)
Add-Type -AssemblyName PresentationCore,PresentationFramework; $ButtonType = [System.Windows.MessageBoxButton]::Ok; $MessageIcon = [System.Windows.MessageBoxImage]::Exclamation; $MessageBody = "This computer will reboot overnight. if you have any questions or concerns call ***********";$MessageTitle = "Computer will reboot";$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
This returns as successful but nothing happens

 

Download: 
script saved to our automate server saved to temp folder on customers computer.
Shell:
powershell.exe -File %windir%\Temp\Computerwillreboot.ps1
This returns as successful, the file is on the computer at the required location but it does not trigger.
if i use command prompt on the computer putting the second part. it work. if i use the labtech cmd interface it returns "ok" but nothing happens.

 

I know this is possible but

I do not know de wey

 

Share this post


Link to post
Share on other sites

@ATrotterYou just need to run your command from `console shell` on the proper console number so the popup displays on their desktop. If you just run default Automate commands it's going to send that popup to the `system` desktop....so obviously the user will never see it. The key here is %consolenumber%, which will be the console number of the logged in user. %consolenumber% will not have a value until you GET the value though, so here is what you need to do...

  1. Use the script function "IF Console Logged On". Leave the username blank, then tell it what label to go to if a user IS logged in like :loggedOn
  2. After your :loggedOn label, insert another line and use the script function "Console Shell", put your command in the command text box, then fill out the Console Number box with %consolenumber% (which now = the console number of the user detected to be logged in from step 1)

That's it! I use powershell popups quite a bit like this. 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×