cls
write-host "`t`t`t Windows Oparation `t`t`t`n" -backgroundcolor black -foregroundcolor yellow
"`n"
Write-Host "1.Services `n2.Process`n3.Events `n4.Hotfixes" -backgroundcolor yellow -foregroundcolor RED
$choice=read-host "Enter Your choice in (1,2,3,4): "
If ($choice -eq 1)
{
write-host "Windows Service" -backgroundcolor yellow -foregroundcolor gray
$status= read-host "Enter the status you want to search ? (running/Stopped)"
$displayname = read-host "Enter the disaply name you want ? (use * for wildcard search) "
get-service|where-object {$_.displayname -like "$displayname" -and $_.status -eq "$status"} |sort-object displayname |format-table Status,DisplayName,starttype
}
elseif ($choice -eq 2)
{
write-host "Windows process" -backgroundcolor yellow -foregroundcolor gray
$Lower = read-host "Enter the Lower Limit for Handles? "
$Upper = read-host "Enter the Upper Limit for Handles? "
get-process |where-object {$_.Handles -gt "$Lower" -and $_.Handles -lt "$Upper"} | sort-object Handles |format-table Handles,ProcessName,StartTime
}
elseif ($choice -eq 3)
{
write-host "`t`t`t Windows eventlog `t`t`t`n" -backgroundcolor yellow -foregroundcolor gray
$application =read-host "ENter the log name ? (Logname Application/HardwareEvents/..etc)"
[string]$Entrytype =read-host "Enter the Entrytype ? (Entery type Error/Warning/Information )"
get-eventlog -logname $application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.EntryType -eq "$EntryType"} | format-table TimeGenerated,Source,EntryType
}
elseif ($choice -eq 4)
{
write-host "`t`t`t Windows HotFixes" -Backgroundcolor Red -ForegroundColor Black
$description=read-host "ENter the description name (Update/Security Update) ?"
$date=read-host "enter the date format (Based on ur system date 12/26/2019 12:00)"?
get-hotfix |where-object {$_.Description -eq "$description" -and $_.installedon -gt "$date"} |format-table PSComputerName,HotFixID,Caption,installedon
}
else
{
write-host "End of script" -backgroundcolor green
}
Search This Blog
Sunday, 2 August 2020
Script-with variables:
cls
write-host "`t`t`t Windows Oparation `t`t`t`n" -backgroundcolor black -foregroundcolor yellow
"`n"
write-host "Windows Service" -backgroundcolor yellow -foregroundcolor gray
$status= read-host "Enter the status you want to search ? (running/Stopped)"
$displayname = read-host "Enter the disaply name you want ? (use * for wildcard search) "
get-service|where-object {$_.displayname -like "$displayname" -and $_.status -eq "$status"} |sort-object displayname |format-table Status,DisplayName,starttype
write-host "Windows process" -backgroundcolor yellow -foregroundcolor gray
$Lower = read-host "Enter the Lower Limit for Handles? "
$Upper = read-host "Enter the Upper Limit for Handles? "
get-process |where-object {$_.Handles -gt "$Lower" -and $_.Handles -lt "$Upper"} | sort-object Handles |format-table Handles,ProcessName,StartTime
write-host "`t`t`t Windows eventlog `t`t`t`n" -backgroundcolor yellow -foregroundcolor gray
$application =read-host "ENter the log name ? (Logname Application/HardwareEvents/..etc)"
[string]$Entrytype =read-host "Enter the Entrytype ? (Entery type Error/Warning/Information )"
get-eventlog -logname $application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.EntryType -eq "$EntryType"} | format-table TimeGenerated,Source,EntryType
write-host "`t`t`t Windows HotFixes" -Backgroundcolor Red -ForegroundColor Black
$description=read-host "ENter the description name (Update/Security Update) ?"
$date=read-host "enter the date format (Based on ur system date 12/26/2019 12:00)"?
get-hotfix |where-object {$_.Description -eq "$description" -and $_.installedon -gt "$date"} |format-table PSComputerName,HotFixID,Caption,installedon
write-host "End of script" -backgroundcolor green
write-host "`t`t`t Windows Oparation `t`t`t`n" -backgroundcolor black -foregroundcolor yellow
"`n"
write-host "Windows Service" -backgroundcolor yellow -foregroundcolor gray
$status= read-host "Enter the status you want to search ? (running/Stopped)"
$displayname = read-host "Enter the disaply name you want ? (use * for wildcard search) "
get-service|where-object {$_.displayname -like "$displayname" -and $_.status -eq "$status"} |sort-object displayname |format-table Status,DisplayName,starttype
write-host "Windows process" -backgroundcolor yellow -foregroundcolor gray
$Lower = read-host "Enter the Lower Limit for Handles? "
$Upper = read-host "Enter the Upper Limit for Handles? "
get-process |where-object {$_.Handles -gt "$Lower" -and $_.Handles -lt "$Upper"} | sort-object Handles |format-table Handles,ProcessName,StartTime
write-host "`t`t`t Windows eventlog `t`t`t`n" -backgroundcolor yellow -foregroundcolor gray
$application =read-host "ENter the log name ? (Logname Application/HardwareEvents/..etc)"
[string]$Entrytype =read-host "Enter the Entrytype ? (Entery type Error/Warning/Information )"
get-eventlog -logname $application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.EntryType -eq "$EntryType"} | format-table TimeGenerated,Source,EntryType
write-host "`t`t`t Windows HotFixes" -Backgroundcolor Red -ForegroundColor Black
$description=read-host "ENter the description name (Update/Security Update) ?"
$date=read-host "enter the date format (Based on ur system date 12/26/2019 12:00)"?
get-hotfix |where-object {$_.Description -eq "$description" -and $_.installedon -gt "$date"} |format-table PSComputerName,HotFixID,Caption,installedon
write-host "End of script" -backgroundcolor green
Powershell-firstscript
#q1: find the services are running and disaply is starting with windows the o/p should contain only status,display,starttype
get-service|where-object {$_.displayname -like "windows*"} |sort-object displayname |format-table Status,DisplayName,starttype
get-service|where-object {$_.displayname -like "windows*" -and $_.status -eq "running"} |sort-object displayname |format-table Status,DisplayName,starttype
get-process |where-object {$_.Handles -gt 500 -and $_.Handles -lt 600} | sort-object Handles |format-table Handles,ProcessName,StartTime
get-eventlog -logname application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.EntryType -eq "Error"} | format-table TimeGenerated,Source,EntryType
get-service|where-object {$_.displayname -like "windows*"} |sort-object displayname |format-table Status,DisplayName,starttype
get-service|where-object {$_.displayname -like "windows*" -and $_.status -eq "running"} |sort-object displayname |format-table Status,DisplayName,starttype
get-process |where-object {$_.Handles -gt 500 -and $_.Handles -lt 600} | sort-object Handles |format-table Handles,ProcessName,StartTime
get-eventlog -logname application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.EntryType -eq "Error"} | format-table TimeGenerated,Source,EntryType
get-hotfix |where-object {$_.Description -eq "update" -and $_.installedon -gt "12/26/2019 12:00"} |format-table PSComputerName,HotFixID,Caption,installedon
###########################################################
Subscribe to:
Posts (Atom)