Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param (
- [string]$ipAddress,
- [string]$message
- )
- # Function to check if a computer is online
- function Test-ComputerOnline {
- param (
- [string]$ipAddress
- )
- $ping = Test-Connection -ComputerName $ipAddress -Count 1 -Quiet
- return $ping
- }
- # Check if the target IP is online
- if (Test-ComputerOnline -ipAddress $ipAddress) {
- try {
- msg.exe * /server:$ipAddress $message
- Write-Output "Message sent to $ipAddress"
- } catch {
- Write-Output "Failed to send message to $ipAddress"
- }
- } else {
- Write-Output "$ipAddress is not online"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement