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
###########################################################
Saturday, 25 July 2020
POWER SHELL
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
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
Wednesday, 5 December 2018
python_exapmle_bank_login_check
'''
Date: 05-Dec-2018
Name: Raja
Des: 1. Validate the user name and pass
2. Test sys.argv for the bank login with Dictionary concept
'''
import sys
if (len(sys.argv) !=2):
sys.exit(1)
bank_name=sys.argv[1]
print ("welcome to ",bank_name)
user_dt={'ganesh':'Password','vinayaka':'Password'}
user_name=input("enter the username : \n")
pwd=input("enter the pass : \n")
user_lst=user_dt.keys()
if user_name in user_lst:
if (pwd ==user_dt[user_name]):
print("login sucess")
else:
print("pass invalid")
sys.exit(1)
else:
print("invalid user")
sys.exit(1)
print("hello Mr. ",user_name)
Date: 05-Dec-2018
Name: Raja
Des: 1. Validate the user name and pass
2. Test sys.argv for the bank login with Dictionary concept
'''
import sys
if (len(sys.argv) !=2):
sys.exit(1)
bank_name=sys.argv[1]
print ("welcome to ",bank_name)
user_dt={'ganesh':'Password','vinayaka':'Password'}
user_name=input("enter the username : \n")
pwd=input("enter the pass : \n")
user_lst=user_dt.keys()
if user_name in user_lst:
if (pwd ==user_dt[user_name]):
print("login sucess")
else:
print("pass invalid")
sys.exit(1)
else:
print("invalid user")
sys.exit(1)
print("hello Mr. ",user_name)
Subscribe to:
Posts (Atom)