Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

Sunday, 21 June 2015

Powershell Script to get Event from Application Event Log

Powershell Script to get particual Event from Application Event Log



.You can use the below script to get Eventlog message using Powershell.

$Server='Your Computer Name"
$Yesterday="From Date in DD/MM/YYYY format"
$Today="To Date in DD/MM/YYYY format"
$Event = "Event ID you are looking for"
Get-EventLog -ComputerName $Server -LogName "Application" -after $Yesterday -before $Today| where {$_.EventID -eq $Event}

Sunday, 4 January 2015

Powershell Script to put Multiple Computers in Maintenance mode in SCOM 2007 R2

Powershell Script to put Multiple Computers in Maintenance mode in SCOM 2007 R2


You can use the below script to add Mutiple Computer in Maintenance mode in SCOM 2007 R2

$comparr= get-content -file "c:\scomscripts\servert.txt"

$starttime = "12/25/2014 22:00" # Change the Starttime
$EndTime = "12/27/2014 23:00"   # Change the Endtime

foreach($Computer in #comparr)

{
$objComputer =Get-agent | where-object {$_.Name -match $computer

$objComputer.HostComputer | New-MaintenaceWindow -StartTime:$starttime -EndTime:$EndTime -Comment" "Server in MM mode"
}