01-12-2023 03:18 PM
I'm currently in the process of developing a simple script to delete caches and cookies, but I want a msgbox to appear to the user currently signed into the desktop. I have tested this part of the script locally and it works perfectly fine.
The Script:
#Testing Msg box alone#
Add-Type -AssemblyName PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::Ok
$MesssageIcon = [System.Windows.MessageBoxImage]::Warning
$MessageBody = "Please save anything open in your current Web Browser, this includes Google Chrome, Microsoft Edge, and Mozilla FireFox and close each one respectively.
We will be deleting your cache and cookies.
-IT"
$MessageTitle = "Read Me"
$Result = [System.Windows.MessageBox]::Show($MessageBody, $MessageTitle,$ButtonType,$MesssageIcon)
When I try to add the Script to Jump Cloud commands itself and run it, it'll error out with a Function timeout error of 124.
I even tried using the file download feature of Jump Cloud, where you can download a file before the command is run in C:\Windows\Temp. Then having the command, itself point to that location and run the script. Unfortunately, this still provides a Function error of 124.
I guess I'm confused as to why I can get it to work locally but not via JC Remote command.
Any advice would be greatly appreciated.
Solved! Go to Solution.
01-12-2023 04:29 PM
Have you tried running this using the RunAsUser module?
# If PSModule RunAsUser is not installed, install it
if ( -not (get-installedModule "RunAsUser" -ErrorAction SilentlyContinue)) {
install-module RunAsUser -force
}
$Command = {
#Testing Msg box alone#
Add-Type -AssemblyName PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::Ok
$MesssageIcon = [System.Windows.MessageBoxImage]::Warning
$MessageBody = "Please save anything open in your current Web Browser, this includes Google Chrome, Microsoft Edge, and Mozilla FireFox and close each one respectively.
We will be deleting your cache and cookies.
-IT"
$MessageTitle = "Read Me"
$Result = [System.Windows.MessageBox]::Show($MessageBody, $MessageTitle,$ButtonType,$MesssageIcon)
}
invoke-ascurrentuser -scriptblock $Command
01-12-2023 04:29 PM
Have you tried running this using the RunAsUser module?
# If PSModule RunAsUser is not installed, install it
if ( -not (get-installedModule "RunAsUser" -ErrorAction SilentlyContinue)) {
install-module RunAsUser -force
}
$Command = {
#Testing Msg box alone#
Add-Type -AssemblyName PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::Ok
$MesssageIcon = [System.Windows.MessageBoxImage]::Warning
$MessageBody = "Please save anything open in your current Web Browser, this includes Google Chrome, Microsoft Edge, and Mozilla FireFox and close each one respectively.
We will be deleting your cache and cookies.
-IT"
$MessageTitle = "Read Me"
$Result = [System.Windows.MessageBox]::Show($MessageBody, $MessageTitle,$ButtonType,$MesssageIcon)
}
invoke-ascurrentuser -scriptblock $Command
01-13-2023 09:37 AM - edited 01-13-2023 09:41 AM
I have not used the RunAsUser Module, and just researched it after you sent this in.
The code you added onto it made it work!
Thank you so much for your help!
New to the site? Take a look at these additional resources:
Ready to join us? You can register here.