Power Shell Basic Commands 1

#Get-command - Retrieves a list of PowerShell command lets

#search Command lets with verb and noun
Get-Command -verb "get"
Get-Command -noun "service"

#Find syntax of cmdlets
Get-Help Get-Command
#to clear window

#to find parameters
Get-Command -?
Get-childItem -?

#To list the directory

#find dos alias in PowerShell

#set location path
set-Location "c:\"

#pipelining command lets by adding in another cmdlet to another
#in the following example, I am asking to list the files in C directory which is >1000kb
Get-ChildItem |where-object{$_.Length -gt 1000kb}
#list files with lenght less than 100 kb
Get-ChildItem |Where-object{$_.Length -lt 100kb}
#List files where letter starts H
Get-ChildItem  |Where-object{$_.Name -eq "hari"}
#sort files by length
Get-ChildItem |where-object{$_.Length -gt 100kb} | Sort-Object Length|Format-Table -property Name,path,Length -AutoSize
#use select object to get properties of an object
Get-ChildItem|Select-object Name,Length,path

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s