I am wanting the ability to send an "Alert Styled Message" to a specific computer on the domain.
Problem 1:
Currently, I have the following as the Alert and If I run it from within Powershell, I get the popup exactly how I want. If I run it outside POwershell )right click, run with POwershell ISE) it does nothing.
Here is the code I have for this part:
$ALERT = {Please contact the I.T. Help Desk @EXT 777.
Reference ERROR CODE: 910978
}
$MYALERT = [System.Windows.Forms.MessageBox]::Show("$ALERT ","I.T.
DEPARTMENT ALERT !", "ok","Warning”)
$MYALERT
Problem 2:
I want to be able to prompt the user for a computer name, and send the alert to that specific computer. I can not get this to work at all... although it did work once, from within powershell but after running it outside powershell it never worked again. Nonetheless, running outside powershell did not ever work at all.
Here is the code I have for this part:
cls
echo ""
echo ""
$name = read-host "Enter computer name "
$ALERT = {Please contact the I.T. Help Desk @EXT 777.
Reference ERROR CODE: 910978
}
$MYALERT = {
[System.Windows.Forms.MessageBox]::Show("$ALERT ","I.T. DEPARTMENT ALERT !",
"ok","Warning”)
}
Invoke-WmiMethod -Path Win32_Process -Name Create -ArgumentList $MYALERT -
ComputerName $name
pause
cls
echo ""
echo " Message Sent. Returning to Main Menu"
cls
EXIT
I do, however get the following output on the console window:
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId :
ReturnValue : 9
PSComputerName :
NOTE: I am not actually wanting to send error codes in this fashion, was just typing something in as an example. I want to use this to send a message to a specific computer on the domain, so that it shows up on top of any open windows and shows up as an alert as opposed to a message from a user.
Also, It seems that for PROBLEM #1, Adding "Add-Type -AssemblyName System.Windows.Forms" at the top allows this to work outside of Powershell. However, after adding the same for PROBLEM #2, it still does not work.
I suspect this might have something to do with it working on my local login because I am logged in, but something is stopping me from execting this on the remote machine.
Any idea on what I am doing wrong?
Thanks in advance!