Script a week – week 00000010
The script below will allow you to send messages to computers with a certain name or with a certain naming convention.
####Script by Chris of TECHGUYBLOG.CO.UK (C) 2018
####Tested on PS 5.0 AND 6.0
####The script below will allow you to send messages to computers with a certain name or with a certain naming convention.
$compname = read-host "Enter computname Do not include * For wild card. IE PCNAME"
$computers = Get-ADComputer -Filter "Name -like '$compname*'" | `
select-object -expandproperty name
$msg = read-host "Please enter your message."
$Time = Read-host "Enter time to display message"
ForEach ($computer in $computers) {
WRITE-HOST $computer
Invoke-WmiMethod `
-Path Win32_Process `
-Name Create `
-ArgumentList "msg * /time:$time $msg" `
-ComputerName $computer
}
PS Version – Test on 5.0 & 6.0
OS – Tested on Windows 7 & Windows 10, with the script being run on a windows 10 machine
Administrative Credentials required – Yes
Changes needed? – Modifying comments to suit your org needs
Additional Things – RPC Turned on
