11
Mar 16

#==================================================================
#==== I needed a quick one liner to check the eventlogs for an application that stopped.
#==== Script looks at a text file with server names then scans both system and application log for the last day for messages
#==================================================================


$servers = Get-Content -Path C:\PowershellScripts\Servers.txt
ForEach ($server in $servers)
{
	Get-Eventlog -ComputerName $server -LogName system -EntryType information -After (Get-Date).AddDays(-1) | where-object { $_.Message -Like "*Stopped*" } | select MachineName, TimeWritten, message
	Get-Eventlog -ComputerName $server -LogName application -EntryType information -After (Get-Date).AddDays(-1) | where-object  { $_.Message -Like "*stopping*" } | select MachineName, Source, TimeWritten, message
}

20
May 15
#==================================================================
#==== I needed a script or command line to check memory for a set of processes.
#==================================================================

PS C:\ get-process -computername ServerName1,ServerName2,ServerName3,ServerName4 Notepad,jbosssvc,Outlook,WINWORD|select name,@{l="WorkingSet(MB)}"; e={$_.WorkingSet64 / 1mb}},machinename |sort-object -property Name |ft -AutoSize

Name WorkingSet(MB)} MachineName
---- --------------- -----------
Outlook 30.06640625 ServerName4
Outlook 28.8203125 ServerName3
Outlook 29.53125 ServerName2
Outlook 31.00390625 ServerName1
jbosssvc 2.78125 ServerName3
jbosssvc 2.765625 ServerName4
jbosssvc 2.76953125 ServerName2
jbosssvc 2.76953125 ServerName1
Notepad 20.6484375 ServerName3
Notepad 18.9453125 ServerName4
Notepad 18.8828125 ServerName2
Notepad 128.2734375 ServerName1
WINWORD 146.81640625 ServerName3
WINWORD 134.51953125 ServerName4
WINWORD 270.34765625 ServerName1
WINWORD 122.6875 ServerName2



20
May 15
#==================================================================
#==== Simple one liner to run a query for printers to see if things change.
#==== I needed something I could run to see if the default printer changed.
#==================================================================
PS C:\> while ($true) {Get-WmiObject -Class Win32_printer | select Name, Default| ft -autosize;start-sleep 5}

Name Default
---- -------
\\PRINTSRVTP01\HP_3505 True

Name Default
---- -------
\\PRINTSRVTP01\HP_3505 True