Popup on Remote Client : Update warning

Hi,

I’m a bit stuck with a fct which is part of a larger script to update a software.

function Lock-user {
    [CmdletBinding()]
    param(
    
        [String]$RemoteMachine
    )
    
    #$RemoteMachine = "localhost"
    
    Write-Verbose "Lock-User Enter for $RemoteMachine"

    $Scriptblock={
    
    $wshell = New-Object -ComObject Wscript.Shell
    $wshell.Popup("Do you want to update charlemagne Software ? `n`n Note : This will close all active instances",3,"Mise a jour de Charlemagne",0x1)
    
    #C:\windows\system32\msg.exe * "Mise a jour de Charlemagne. `n`n Note : cela va fermer toutes les instances active"
    
    if($? -eq 1 -or $? -eq -1){
             
        if (Get-Process -Name Administratif -ErrorAction SilentlyContinue){ (Get-Process -Name Administratif).kill()}
        
        }
      
    }#end Scriptblock

    Invoke-Command -ComputerName $RemoteMachine -ScriptBlock $Scriptblock

}#End Lock-user

Is it Possible to specify which user will receive the popup with $wshell.Popup if not how can i recover the ok button value for msg.exe

Thanks for taking the time to review.

CM

If what you’re trying to do is pop up a message in front of the remotely logged-on user, Windows makes that extremely difficult, on purpose, for security reasons. Invoke-Command isn’t logging onto the remote user’s session, it’s creating a new session for YOU. I think every administrator tries this at some point, and then realizes that Windows is a multi-user operating system and it places extremely hard boundaries between user sessions. The only reliable way to get a GUI in front of a user is to have it running under that user’s logon. For example, as a logon script.

Logon script would not work in my case, as the script is made for a specific software (poorly written in windev) that i often have to update on last minute in the middle of the day.

Thanks for your time, i’ll do this in 2 times first a warning and then the full script 10 minutes later and be cursed, yet again ;o

CM