PowerShell Basics

Powershell and Sharepoint Management shell


Difference

Powershell is available with windows OS and it can be used to do some actions very easily
But sharepoint management shell is available with sharepoint product and it have some additional sharepoint powershell snapin preloaded. But we can manually load this snapin in windows powershell

How?

Run this command in windows powershell

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

Additional Commands available in powershell












Get Help for Powershell commands



Basic Keyword for Powershell

How to Write to powershell winndow

Write-Host "Anything"

Exit powershell

exit

Keywords

-li
-le
-ge
-eq
-ne
-like
-notlike
-ceq = Case sensite equslity.
*Ex = Anything before Ex

Basic Script for powershell


Find All the command availbale in powershell

Get-Command

Help for a particular command

Get-Help Get-Command -examples

Detailed help for a command

Get-Help Get-Command -detailed

Get all the process running

Get-Process | Where-Object{$_.ProcessName -like ^w*} | -format list ProcessName

Get-Process | Where-Object{$_.ProcessName -like "w*"}

Set location

Set=location C:
C:/

Use a saved powershell commands.

powershell.exe -command "& {.\demo.ps1}"

Pause the powershell

pause

Clear the powershell window

cls

Powershell commands are similar to .net objects

$date = New-Object -TypeName System.DateTime -ArgumentList @(2010,9,5)

$message = "Date: "+$date.ToLongDateString()

:: is used to call the statis members

$today = [System.DateTime]::Today


















No comments:

Post a Comment