Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Starting Powershell
#1. Start the command prompt - C:WindowsSystem32cmd.exe
#2. Type the command: powershell and press Ent...
Get-Process
#Currently running processes
Get-Process
#To see the output of the command page by page
Get-Process | more
# T...
Stop-Process
#Stop the notepad process
Stop-Process -Name notepad
#Stop the chrome browser process
Stop-Process -Name chro...
Start-Process
#start notepad process
Start-Process notepad
#Start powershell process as administrator
Start-Process powers...
Get-System Information Powershell
#to get the environment settings. The output grid view provides nice GUI
Get-ChildItem E...
Get-Help Help Powershell
#Look for help for specific command
Get-Help Get-Process | more
#View the example for specific co...
Get-Eventlog Powershell Basics
#List of Eventlog's available
Get-EventLog -List
#Local computer Application eventlog
Get-E...
Get-Service Powershell
#List the windows services in the system
Get-Service | more
#list the services that matches name li...
Stop-Service Start-Service Powershell
#Stop a specific service
Stop-Service SQLBrowser
#Stop the Service by viewing the se...
Import-Csv Powershell Basics
<# Sample CSV File data is given below
Name,Status,Salary,Pay Basis,Position Title
"Aberger, ...
Import-Csv Powershell Basics
<# Sample CSV File data is given below
Name,Status,Salary,Pay Basis,Position Title
"Aberger, ...
Upcoming SlideShare
Loading in …5
×

Windows productivity powershell for everyone

281 views

Published on

Become productive in Windows environment. Learn simple and Powerful Powershell commands and enjoy Windows

Published in: Education
  • Be the first to comment

  • Be the first to like this

Windows productivity powershell for everyone

  1. 1. Starting Powershell #1. Start the command prompt - C:WindowsSystem32cmd.exe #2. Type the command: powershell and press Enter/Return key # To start the powershell command prompt as administrator: Go to: C:WindowsSystem32WindowsPowerShellv1.0 Select powershell.exe. Right click: Click Run As Administrator
  2. 2. Get-Process #Currently running processes Get-Process #To see the output of the command page by page Get-Process | more # To find processes that takes more memory, working set > 100 MB Get-Process | where-object {$_.WorkingSet -gt 100MB} #To find all the programs that are running and, the path from which they are running get-process -fileversioninfo | Select ProductName, FileName | Out-GridView #Check whether specific process is running gps powershell #search for process names using wild cards gps | where {$_.Name -like "*win*"}
  3. 3. Stop-Process #Stop the notepad process Stop-Process -Name notepad #Stop the chrome browser process Stop-Process -Name chrome #To stop all the browsers that are currently running Get-Process chrome, firefox, iexplore | Stop-Process #Find the processes that is consuming more memory and stop it Get-Process | where-object {$_.WorkingSet -gt 100MB} #stops only the process id: 7992 Stop-Process -id 7992 #stops all the processes Get-Process | where-object {$_.WorkingSet -gt 100MB} | Stop-Process #To stop sqlserver related processes Get-Process sql* | Stop-Process
  4. 4. Start-Process #start notepad process Start-Process notepad #Start powershell process as administrator Start-Process powershell.exe -verb runas #Start a powershell process in a new window Start-Process powershell.exe -verb open #start the process and redirect its output to a file Start-Process C:PS_Testhello.bat -workingdirectory "C:PS_Test" - RedirectStandardOutput C:PS_Testhello.txt #Start a process with command line arguments $msbuild = "C:WINDOWSMicrosoft.NETFrameworkv4.0MSBuild.exe" $arguments = "/v:q /nologo" Start-Process $msbuild $arguments
  5. 5. Get-System Information Powershell #to get the environment settings. The output grid view provides nice GUI Get-ChildItem Env: | select-object Name,Value | Out-GridView #How much RAM installed in the computer Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property @{Name="Total Memory (GB)"; Expression = {$_.TotalPhysicalMemory/1GB}} #to get the user-path settings. The output grid view provides nice GUI with filter $env:Path.Split(";") | Out-GridView #to get the system-path settings. The output grid view provides nice GUI with filter [Environment]::GetEnvironmentVariable("Path", "Machine").Split(";") | Out-GridView #To Set a new system environment variable [Environment]::SetEnvironmentVariable("ResharperPath", "C:ResharperPathbin", "Machine") #To Set the user environment variable [Environment]::SetEnvironmentVariable("UserData", "D:User100Data", "user")
  6. 6. Get-Help Help Powershell #Look for help for specific command Get-Help Get-Process | more #View the example for specific command Get-Help Get-Process -examples | more #Look for commands that contains Process Get-Help *Process* | more #Look for commands that contains csv Help *csv* | more #Look for commands that contains HTML Help *HTML* | more #Look for commands that contains Computer Help *Computer* | more #Update help from internet Update-Help
  7. 7. Get-Eventlog Powershell Basics #List of Eventlog's available Get-EventLog -List #Local computer Application eventlog Get-EventLog -Newest 20 -logname Application | Out-GridView #Local computer Application eventlog Get-EventLog -Newest 20 -logname System -entrytype Error| Out- GridView #Searching for specific messages Get-EventLog -Newest 1000 -logname System -entrytype Error| where {$_.Message -like "*10028*"} | Out-GridView #Specific source application - outlook Get-EventLog -log application -source outlook | Out-GridView #powershell error log Get-EventLog -log "Windows PowerShell" -entrytype Error -Newest 100 | Out-GridView
  8. 8. Get-Service Powershell #List the windows services in the system Get-Service | more #list the services that matches name like *win* get-service -name *win* #list the services that matches DisplayName like *sql* get-service -DisplayName *sql* #another simple way to retrieve services "*sql*" | get-service #list the services that are currently running get-service | where {$_.Status -eq "Running"} | more #list the services - order by status get-service | sort status | more
  9. 9. Stop-Service Start-Service Powershell #Stop a specific service Stop-Service SQLBrowser #Stop the Service by viewing the services and then filtering "*sql*" | Get-Service "*sql*" | Get-Service | where {$_.Name -eq "SQLWriter"} | Stop-Service "*sqlwriter*" | Stop-Service #Forcefully stopping the services, by asking confirmation "*sqlwriter*" | Get-Service | Stop-Service -Force -Confirm #Start Service Start-Service -name eventlog #Start all the sql* services, which are not currently running "*sql*" | get-service | where {$_.status -eq "Stopped"} | Start-Service #set the service startup type to manual "*sql*" | get-service | set-service -startuptype manual #Check the service startup type Get-WMIObject Win32_Service | Select-Object Name, Caption, StartMode | where {$_.Name -like '*sql*'}
  10. 10. Import-Csv Powershell Basics <# Sample CSV File data is given below Name,Status,Salary,Pay Basis,Position Title "Aberger, Marie E.",Employee,"$42,000.00",Per Annum,PRESS ASSISTANT Sample CSV File data end #> #Import-Csv File into memory. Entire file is in memory. Import-csv -Path "D:employee_data.csv" | Measure-Object | Select- Object Count #Import the file and assign it to variable $csvFile = Import-csv -Path "D:employee_data.csv" $csvFile | Select-Object -First 4 | Format-Table #First 4 rows $csvFile | Select-Object -Last 4 | Out-GridView #Last 4 rows $csvFile | Group-Object "Status“ | Out-GridView #group by status #group by “Position Title” $csvFile | Group-Object "Position Title“ | Out-GridView #group by “Position Title”, count greater than 5 $csvFile | Group-Object "Position Title" | where {$_.Count -gt 5}
  11. 11. Import-Csv Powershell Basics <# Sample CSV File data is given below Name,Status,Salary,Pay Basis,Position Title "Aberger, Marie E.",Employee,"$42,000.00",Per Annum,PRESS ASSISTANT Sample CSV File data end #> #Import the file and assign it to variable $csvFile = Import-csv -Path "D:employee_data.csv“ #Search for Name like *mar* $csvFile | where {$_.Name -like '*mar*'} | Out-GridView #Search for: Status=Employee and position = Press Assitant $csvFile | where {$_.Status -eq "Employee" -and $_."Position Title" -eq "PRESS ASSISTANT"} | Out-GridView #Total, minimum, maximum, average salary of first 5 employees $csvFile | Select-Object -First 5 |Select-Object -Property @{Name="Salary"; Expression = { $_.Salary -replace '[^0-9.]'}} | Measure-Object -Property Salary -minimum -maximum -average -sum #Total, minimum, maximum, average salary of All employees $csvFile | Select-Object -Property @{Name="Salary"; Expression = { $_.Salary -replace '[^0-9.]'}} | Measure-Object -Property Salary - minimum -maximum -average -sum

×