End user text prompts for software removal?

Hello all – We need to in remove some software, but give the user notice on-screen before and after. When the software is removed, it must be in silent mode (or the user will be able to cancel it). I need two prompts and thinking PowerShell is the best bet. We have the software removal part working and don’t need help on that. Just end user notification prompts.

  1. First prompt. Notification pops up with something like “This software will uninstall.” Then have a countdown where it hits zero, it proceeds to software removal. Or if the user doesn’t want to wait until it hits 0, they can hit ‘Start Now’ and then it exits the script.
  2. Software removed.
  3. Second prompt. Another prompt to the user that simply says, ‘Update Complete.’ They hit okay and script exits.

Do any of you know if there are PowerShell script that would do this?

A simply Message Box with OK is basically a one liner. The countdown timer part may require that you use a Windows Form which adds more complexity.

https://ss64.com/ps/messagebox.html

This script I got to do what I need. However what happens is when it’s sent remotely to the pc, on the pc itself you can see the powershell window open up in the background, and then the prompt appears on screen. Is there a way to prevent the powershell window from showing, but still have the script present itself on screen?

Add-Type -AssemblyName PresentationFramework, WindowsBase

$Form = [Windows.Markup.XamlReader]::Load((New-Object Xml.XmlNodeReader([xml]@'

<Window Name='Window' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' WindowStartupLocation='CenterScreen' WindowStyle='None' WindowState='Normal' Width='300' Height='280' Background='#FFFFFF' Topmost='True' ResizeMode='NoResize' AllowsTransparency='True' >

<Border BorderBrush="#0178D6" BorderThickness="2" Height="280" Margin="0,0,0,0" VerticalAlignment="Top" Width="300">

<Grid>

<Button Name='Minimize' Content='_' HorizontalAlignment='Right' VerticalAlignment='Top' Padding='0,10,0,10' FontSize='20' Background='#0178D6' Foreground='White' Margin='0,5,5,0' Width='30' Height='30' />

<StackPanel HorizontalAlignment='Center' VerticalAlignment='Top' Margin='0,30,0,0'>

<StackPanel HorizontalAlignment='Center' VerticalAlignment='Top' Margin='0,10,0,0'>

<Label Name='Title' Content='Microsoft Update Required' HorizontalAlignment='Center' FontSize='20' Foreground='Red'/>

<Label Content='Save All Open Work' HorizontalAlignment='Center' FontSize='30' Foreground='Red' Margin='0,20,0,0'/>

<Label Name='Countdown' Content='' HorizontalAlignment='Center' FontSize='14' Foreground='Black' Margin='0,20,0,0'/>

</StackPanel>

</StackPanel>

<StackPanel Margin='0,0,0,30' VerticalAlignment='Bottom'>

<Button Name='Install' Content='Update Now' Width='Auto' HorizontalAlignment='Center' Padding='20,10,20,10' FontSize='14' Background='#0178D6' Foreground='white'/>

</StackPanel>

</Grid>

</Border>

</Window>

'@)))

$Minimize=$Form.FindName('Minimize')

$OK=$Form.Findname('Install')

$Countdown=$Form.Findname('Countdown')

$Timer = New-Object System.Windows.Threading.DispatcherTimer

$Timer.Interval = [TimeSpan]'0:0:0:1'

$Global:RemainingTime=300

$Timer.Add_Tick{

$Global:RemainingTime=$Global:RemainingTime - 1

$Countdown.Content="Update will begin in $Global:RemainingTime seconds."

If ($Global:RemainingTime -le 0){$Form.close()}

}

$OK.Add_Click{

$Form.close()

}

$Form.Add_SourceInitialized{

$Timer.Start()

}

$Minimize.Add_Click{$Form.WindowState='Minimized'}

$Form.Showdialog()