get-help about_operator
get-help where-object
get-service | where-object {$_.status -eq "running"}
get-service | where-object {$_.name -eq "winrm"}
get-eventlog -list
get-eventlog -logname application -Newest 50 | where-object {$_.EntryType -eq "error"}
get-hotfix | where-object {$_.Description -eq "update"}
not equal:
get-hotfix | where-object {$_.Description -ne "update"}
get-help about_comparison_operators
greater that:
get-process | where-object {$_.Handles -gt "1500"}
less than:
get-process | where-object {$_.Handles -lt "100"}
greater than date:
get-hotfix | where-object {$_.InstalledOn -gt "01/01/2020"}
get-hotfix | where-object {$_.InstalledOn -gt "01/01/2019"}
get-hotfix | where-object {$_.InstalledOn -gt "01-01-2019"}
Like:
get-service | where-object {$_.displayname -like "Application*"}
get-process | where-object {$_.ProcessName -like "*host*"}
get-service | where-object {$_.displayname -like "*manager"}
JULY-26-2020
logical operator:
================
get-help about_logical_operators
AND:
get-service | where-object {$_.Status -eq "running" -and $_.DisplayName -like "windows*"}
get-process | where-object {$_.Handles -gt 500 -and $_.Handles -lt 700}
get-hotfix |where-object {$_.Description -eq "update" -and $_.InstalledOn -gt "01/01/2019"}
get-eventlog -logname application | where-object {$_.timegenerated -gt "07/24/2020 10:00" -and $_.timegenerated -lt "07/24/2020 22:00"}
get-eventlog -logname application | where-object {$_.timegenerated -gt "07/24/2020 10:00" -and $_.timegenerated -lt "07/24/2020 22:00"
-and $_.EntryType -eq "Error"}
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" -and $_.source -like "software*"}
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" -and $_.source -like "software*" -and $_.message -match "activation"}
get-eventlog -logname application | where-object {$_.timegenerated -gt "07/25/2020 10:00" -and $_.timegenerated -lt "07/25/2020 22:00" -and $_.source -like "software*" -and $_.index -eq "51889"}
OR :
get-process |where-object {$_.ProcessName -eq "firefox" -or $_.ProcessName -eq "zoom"}
get-service | where-object {$_.DisplayName -like "network*" -or $_.DisplayName -like "Application*"}
AND & OR
get-process |where-object {$_.Handles -gt 500 -and $_.Handles -lt 700 -or $_.ProcessName -eq "zoom"}
=========
JULY-26:
format-table :
get-help format-table
get-hotfix |where-object {$_.Description -eq "update" -and $_.InstalledOn -gt "01/01/2019"} |format-table Description,HotFixID,InstalledOn
get-process |where-object {$_.Handles -gt 500 -and $_.Handles -lt 600} | format-table Handles,ProcessName,StartTime
get-hotfix |where-object {$_.Description -eq "update"}
get-hotfix |where-object {$_.Description -eq "update"} |format-table PSComputerName,HotFixID,Caption
#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-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
Practise:
get-content -path C:\Users\Katam\Documents\powershell\Lab\script1.ps1 -tail 2
get-eventlog -logname application -newest 10 |format-table TimeGenerated,EventID,Source,EntryType
get-eventlog -logname application -newest 10 |format-table Time*,EventID,Source,EntryType
===========
AUG-01-2020
get-help about_automatic_variable
get-help about_preference_variable
get-help about_profile