Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Deploying Powershell scripts instead of invoking it: Toast, Balloon tip

Hi Guys,

Nice to see you all since this is the first post of mine. 

I have one easy question for you all

Can we use PDQ Deployment instead of PowerShell command Invoke-Command? I tried to do this for Balloon tips with code:

Add-Type -AssemblyName System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balmsg.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText = ‘Your computer needs a restart please restart it immediately.'
$balmsg.BalloonTipTitle = "Restart required"
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(20000)

 

This is a very easy script, when you deploy it on your computer you will receive a notification about to do a restart. But when you want to deploy it on several computers it won't appear. I made some investigations and believe the issue is related because the log on users didn't see notification deployed by PDQ Deploy user. I tried to write a code where I could separate the who is active and who is not by adding a statement IF. The code after change looks like this:

$username = (Get-WmiObject -Class Win32_Process -Filter 'Name="explorer.exe"').GetOwner().User

If($username) {

Add-Type -AssemblyName System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balmsg.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText = ‘Your computer needs a restart please restart it immediately.'
$balmsg.BalloonTipTitle = "Restart required"
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(20000)

}

Still with no effect. Of course, I found out that the only way is to use invoke-command which is turned off in my organization because of security reasons. I tried a number of things such as use GPO to create Task Scheduler when machine is not restarted in 10 days without effect. 

Looking for help maybe someone knows about how to effectively deploy scripts without using invoke-command for Toast or Balloon tips. Or knows different options to notify users. 

Thanks

 

2

Comments

1 comment
Date Votes
  • I use a similar script for notifying the users to restart their systems.

    Go to package settings > Options and set "Run as" as Deploy User (Interactive) then you see the notification under the logged on useraccount.

       

    Another (fully automated) solution is creating a scheduled task, which runs e.g. once a week and checks for the system uptime. If the threshold is reached, the restart notification shows up. I use this with success. The script and scheduled task is copied and created after os-deployment within gpo.

    For special/custom restart notifications I use my custom package in pdq.

     

     

     

    1