SlideShare a Scribd company logo
1 of 43
Welcome to PowerShell Training
Name : Pardha Sai (Pardhu)
Role : Automation Engineer
Course Duration : 10 Hours
Agenda
• What do you know about PowerShell ?
• How Powershell help’s IT ?
• Little History of Powershell
• Variables
• Data Types
• Conditions
• Loops
• What is command let ?
• How to find Cmdlets in PowerShell ?
• 3 important Cmdlets
• What is alias ?
• What is Pipeline and use of where and select object ?
• What is PowerShell profile and how it is used ?
• What is WMI Object ?
Agenda
• What is PowerShell Remoting and
How we can remote ?
• What is function ?
• What is module ?
• How to find and use Modules ?
• What is RSAT ?
• Client VS Server RSAT ?
• Getting Started with AD PS Module ?
• AD Module Version History
• How to import & export CSV data in PS ?
• How to Create Bulk User’s by using CSV File ?
• How to copy a user across AD?
• What is Execution Policy ?
• How to build PowerShell Script ?
What do you know about
PowerShell ???
How Powershell helpful to IT Administrators ???
&
History of powershell
Jeffrey Snover
He is a Distinguished Engineer and the Lead Architect for
the Windows Server Division at Microsoft. He is the inventor
of Windows PowerShell, an object-based distributed
automation engine, scripting language, and command line
shell.
Version of PowerShell
PowerShell V1.0 PowerShell V2.0 PowerShell V3.0 PowerShell V4.0 PowerShell V5.0
• Released in November
2006.
• Supports in Windows XP
SP2,Vista,2003.
• optional component of
Windows Server 2008.
• Supports in Windows 7,2008
R2.
• Also released for Windows XP
SP3,2003 SP2 and Vista SP1.
• PowerShell Remoting
• Modules Supports
• Windows PowerShell Integrated
Scripting Environment (ISE)
• Exception Handling Supports
• APIs Supports
• New Cmdlets
• Supports in Windows 8,2012.
• Also released for win 7
SP1,2008 SP1 and 2008 R2
SP1.
• Help update (Man Pages)
• Automatic module detection
• Session connectivity
• New Cmdlets and Modules
• Supports in Windows
8.1,2012 R2
• Also released for win 7
SP1,2008 R2 SP1 and 2012
R2 SP1.
• Desired State Configuration
• New Default Execution Policy
• Enhanced debugging
• workflow PowerShell
• New Cmdlets and Modules
• Supports in Windows
10,2016 and Nano server
• Also released for win 7,8,8.1
SP1,2008 R2 SP1 and 2012
R2 SP1.
• Oneget/PowerShell get
• PowerShell class definitions
(properties, methods)
• Desired State Configuration
V2.0
• New Cmdlets and Modules
@source : Wikipedia
What is variable ???
Variables
Variables store information temporarily so you can take the information
contained in a variable and process it in further steps.
PowerShell creates new variables automatically so there is no need to
specifically "declare" variables. Simply assign data to a variable. The only
thing you need to know is that variable names are always prefixed with a
"$".
You can then output the variable content by entering the variable name, or
you can merge the variable content into text strings. To do that, just make
sure the string is delimited by double-quotes. Single-quoted text will not
resolve variables.
• Declare Variables
• Selecting Variable Names
• Assigning and Returning Values
• Using Special Variable Cmdlets
• Default Variables
Variables
What is Data Types ???
Data Types
There is an additional and important reason to assign data types manually because every
data type has its own set of special commands. For example, a date can be stored as text in
a String data type. And that's just exactly what PowerShell does: it's not clever enough to
automatically guess that this really is a date or time:
$date = "November 12, 2004“;$date
November 12, 2004
If you store a date as String, then you'll have no access to special date functions. Only
DateTime objects make them available. So, if you're working with date and time indicators,
it's better to store them explicitly as DateTime:
[datetime]$date = "November 12, 2004" $date
Friday, November 12, 2004 00:00:00
The output of the variable will now immediately tell you the day of the week corresponding
to the date, and also enable comprehensive date and time calculation commands. That
makes it easy, for example, to find the date 60 days later:
$date.AddDays(60)
Tuesday, January 11, 2005 00:00:00
Data Types
What are Conditions ???
Conditions
• If Condition
• if-Else Condition
• If-ElseIf-Else Condition
• Switch Condition
#Example : If-elseif-else Condition
$value = 1
If ($value -eq 1)
{
" Number 1"
}
ElseIf ($value -eq 2)
{
" Number 2"
}
ElseIf ($value -eq 3)
{
" Number 3"
}
else
{
" Number does not exists"
}
#Example : Switch Condition
$value = 6
Switch ($value)
{
1 { "Number 1“ }
2 { "Number 2“ }
3 { "Number 3“ }
default
{
"Number does not exists"
}
}
What is Loop ???
Loops
• For Loop
• While Loop
• Do While loop
• For Each loop
• Switch Loop
#Example : For Loop
For ($i = 0 ;$i -lt 5;$i++)
{
$i
}
#Example : While Loop
$i = 0
While ($i -lt 5)
{
$i++
$i
}
#Example : Do While Loop
$i = 0
Do
{
$i++
$i
} While ($i -lt 5)
#Example : For Each Loop
$array = 1..5
Foreach ($element in $array)
{
"Current element: $element"
}
#Example : Switch Loop
$array = 1..5
Switch ($array)
{
Default { "Current element: $_" }
}
Break..Continue
• Break
• Continue
#Example : For Loop with break and continue
For ($i=1; $i -lt 5; $i++)
{
$password = Read-Host "Enter password ($i.
try)"
If ($password -eq "secret")
{
break
}
if ($password -ne "secret")
{
continue
}
}
What is command ???
What is Cmdlet ?
Cmdlet Function
Get-Location get the current directory
Set-Location change the current directory
Copy-Item copy files
Remove-Item remove a file or directory
Move-Item move a file
Rename-Item rename a file
New-Item create a new empty file or directory
A cmdlet (pronounced "command-let") is a lightweight Windows PowerShell script that performs a single function.
A command, in this context, is a specific order from a user to the computer's operating system or to an application to
perform a service, such as "Show me all my files" or "Run this program for me." Although Windows PowerShell
includes more than two hundred basic core cmdlets, administrators can also write their own cmdlets and share them.
How to find cmdlets in PowerShell ???
The folks at Microsoft made several design strategies when
designing PowerShell cmdlets. First is the ability to easily infer cmdlet names,
or at the very least make them easy to discover. PowerShell cmdlets are also
designed to be easy to use with standardized syntax, making them easy to
use interactively from the command line or to create powerful scripts.
PowerShell cmdlets use the Verb-Noun format
Example : Cmdlet Name Verb Noun
Get-Service Get Service
Start-Service Start Service
The verb portion of the cmdlet name indicates the action to be performed on the noun.
Three Important Cmdlets
If you don’t remember anything else
Get-Help : PowerShell has help info backed
right in, Just like “Man” pages in Unix
Get-Member : Since PowerShell is object
aware, This cmdlet helps explore the
methods and Properties within PowerShell
Get-Command : PowerShell’s dictionary lookup, this
will help you to find cmdlets you can use
What is alias ???
An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or
executable file. You can use the alias instead of the command name in any Windows PowerShell commands.
PowerShell (Cmdlet) PowerShell (Alias) CMD.EXE / COMMAND.COM Unix shell Description
Get-ChildItem gci, dir, ls dir ls
List all files / directories in the (current)
directory
Test-Connection/ping N/A ping ping
Sends ICMP echo requests to specified
machine from the current machine, or
instructs another machine to do so
Get-Content gc, type, cat type cat Get the content of a file
Get-Command gcm help type, which, compgen List available commands
Get-Help help, man help apropos, man Help on commands
Clear-Host cls, clear cls clear Clear the screen[b]
Copy-Item cpi, copy, cp copy cp
Copy one or several files / a whole
directory tree
Move-Item mi, move, mv move mv
Move a file / a directory to a new
location
Remove-Item ri, del, erase, rmdir, rd, rm del, erase, rmdir, rd rm, rmdir Delete a file / a directory
Rename-Item rni, ren, mv ren, rename mv Rename a file / a directory
Get-Location gl, cd, pwd cd pwd
Display the current directory/present
working directory.
@source : Wikipedia
Pipeline
You can use pipelines to send the objects that are output by one command to be used as input to
another command for processing. And you can send the output of that command to yet another
command. The result is a very powerful command chain or "pipeline" that is comprised of a series of
simple commands.
Example : Get-Process notepad | stop-process
Get-Service | Where-Object {$_.name -Match "win"}
Get-Service | Where-Object {$_.name -Match "win"} | select Name
A pipeline is a series of commands connected by pipeline operators (|) (ASCII 124) . Each pipeline operator
sends the results of the preceding command to the next command.
What is PowerShell Profile ???
What is WMI ???
WMI
WMI represents the insides of your computer in the form of classes. WMI provides classes for nearly everything:
processor, BIOS, memory, user accounts, services, etc.
The name of a class usually consists of the "Win32" prefix.
For example, the Win32_Service describes services.
Get-WmiObject Win32_BIOS
Get-WmiObject Win32_Process -filter 'name = "powershell.exe"‘
[wmi]"Win32_Service.Name='netman'“
Get-WmiObject win32_service | Where-Object {$_.name -eq "netman"}
Get-WmiObject win32_computersystem | gm
Get-WmiObject win32_computersystem | Select-Object domain
Powershell Remoting
What is Function ???
Functions
Functions are self-defined new commands consisting of general
PowerShell building blocks. They have in principle three tasks:
• Shorthand: very simple shorthand for commands and immediately
give the commands arguments to take along
• Combining: functions can make your work easier by combining
several steps
• Encapsulating and extending: small but highly complex programs
consisting of many hundreds of statements and providing entirely new
functionalities
The basic structure of a function is the same in all three instances: after
the Function statement follows the name of the function, and after that
the PowerShell code in braces.
Example : Shorthand
Function myPing
{
ping localhost
}
Example : Combining
Function NextFreeDrive
{
For ($x=67; $x -le 90; $x++)
{
$driveletter =
[char]$x + ":"
If (!(Test-Path
$driveletter))
{
$driveletter
break
}
}
}
What is Module ???
Modules
A module is a package that contains Windows PowerShell commands, such
as cmdlets, providers, functions, workflows, variables, and aliases.
People who write commands can use modules to organize their commands
and share them with others. People who receive modules can add the
commands in the modules to their Windows PowerShell sessions and use
them just like the built-in commands.
BUILT-IN MODULES :
Microsoft.PowerShell.Core
Microsoft.PowerShell.Diagnostics
Microsoft.PowerShell.Host
Microsoft.PowerShell.Management
Microsoft.PowerShell.Security
Microsoft.PowerShell.Utility
Microsoft.WSMan.Management
PSScheduledJob
PSWorkflow
PSWorkflowUtility
HOW TO USE A MODULE
To use a module, perform the following tasks:
1. Install/Import the module. (This is often done for you.)
2. Find the commands that the module added.
3. Use the commands that the module added.
What is RSAT ???
RSAT (Remote Server Administration Tools)
RSAT (Remote Server Administration Tools) is a Windows
Server component for remote management of other
computers also running that operating system. RSAT was
introduced in Windows Server 2008 R2.
RSAT allows administrators to run snap-ins and tools on a
remote computer to manage features, roles and role
services. The software includes tools for cluster-aware
updating, Group Policy management and Hyper-V
management, as well as the Best Practices Analyzer.
RSAT runs on Windows 7, Windows 8, Windows Server
2008, Windows Server 2008 R2 and Windows Server 2012.
Client RSAT AD VS Server RSAT AD
Client
Windows 7
Windows Server 2008 R2
Windows 8
Windows Server 2012
Windows 8.1
Windows Server 2012 R2
Server
Windows Server 2003 or 2008
AD Management Gateway Service
Windows Server 2008 R2
Windows Server 2012
Windows Server 2012 R2
Port
9389
AD
Cmdlet
Feature
Level
Getting Started with AD PS Module
Active Directory PowerShell History
Former Scripting Technologies
WMI
ADODB
CMD utilities
ADSI (.NET foundation)
PowerShell AD Module
2008 R2 (v1) 76 cmdlets
Forest, Domain
Users, Groups,
Computers, OUs
Service Accounts
Password Policies
Recycle Bin
Etc.
2012 (v2) +69 cmdlets
Replication
Trusts
DC Cloning
Dynamic Access Control
ADDS Deployment
Module
2012 R2 (v3) +12 cmdlets
Authentication Policies
How to import & Export CSV data ???
Bulk User Creation using CSV File
Copy-aduser
* Import the Copy-aduser Function in PowerShell Console
* Once Copy-aduser Function Loaded type below command to Execute it
Example : copy-aduser -fristName "PowerShell" -LastName "Trainer" -userLogonName
"Powershell" -SampleUserName "Pardhu" -password "Test@123"
Function is placed in
below txt file
What is Execution Policy ???
Execution Policy
• Restricted
• AllSigned
• RemoteSigned
• Unrestricted
• Bypass
• Undefined
Windows PowerShell execution policies let you determine the
conditions under which Windows PowerShell loads configuration
files and runs scripts.
You can set an execution policy for the local computer, for the
current user, or for a particular session. You can also use a Group
Policy setting to set execution policy for computers and users.
Execution policies for the local computer and current user are stored
in the registry. You do not need to set execution policies in your
Windows PowerShell profile. The execution policy for a particular
session is stored only in memory and is lost when the session is
closed.
How to build Powershell Script ???
Thank You
To Learn Powershell you have use it more
Here are Some reference Links :
To Learn More : Use Microsoft Virtual Academy
For Practice : Use Microsoft Virtual Labs
For Cmdlets : Use TechNet
Keep up-to-date : Use https://powershell.org/
Name : Pardha Sai (Pardhu)
Role : Automation Engineer
Phone : 9885572999
Email ID : Pardhasai.Vadlamudi@in.fujitsu.com

More Related Content

What's hot

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellSalaudeen Rajack
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel ExploitationzeroSteiner
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questionsKavya Sri
 
Introduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsIntroduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsEric Hogue
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleKnoldus Inc.
 

What's hot (20)

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questions
 
Maven
MavenMaven
Maven
 
Introduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsIntroduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec Jenkins
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Ansible
AnsibleAnsible
Ansible
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Design patterns in PHP
Design patterns in PHPDesign patterns in PHP
Design patterns in PHP
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
 
Ansible
AnsibleAnsible
Ansible
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 

Viewers also liked

Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShellDale Lane
 
Professional Help for PowerShell Modules
Professional Help for PowerShell ModulesProfessional Help for PowerShell Modules
Professional Help for PowerShell ModulesJune Blender
 
PowerShell DSC と連携して監視を効率化してみる
PowerShell DSC と連携して監視を効率化してみるPowerShell DSC と連携して監視を効率化してみる
PowerShell DSC と連携して監視を効率化してみるika ika
 
System Center Configuration Manager 2012 Sneak Peek
System Center Configuration Manager 2012 Sneak PeekSystem Center Configuration Manager 2012 Sneak Peek
System Center Configuration Manager 2012 Sneak PeekC/D/H Technology Consultants
 
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...Lumension
 
What's New in System Center 2012
What's New in System Center 2012 What's New in System Center 2012
What's New in System Center 2012 Perficient, Inc.
 
System Center 2012 R2 - Enterprise Automation
System Center 2012 R2 - Enterprise AutomationSystem Center 2012 R2 - Enterprise Automation
System Center 2012 R2 - Enterprise AutomationScientia Groups
 
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012ITCamp
 
Microsoft system center 2012 r2 configuration manager
Microsoft system center 2012 r2 configuration managerMicrosoft system center 2012 r2 configuration manager
Microsoft system center 2012 r2 configuration managerapponix1
 
World Population Datasheet 2008
World Population Datasheet 2008World Population Datasheet 2008
World Population Datasheet 2008richm711
 
TFS Administration Overview
TFS Administration OverviewTFS Administration Overview
TFS Administration OverviewSteve Lange
 
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...Peter Daalmans
 
Microsoft sccm 2012 seminar ddls sydney 22 nov 2012
Microsoft sccm 2012 seminar   ddls sydney 22 nov 2012Microsoft sccm 2012 seminar   ddls sydney 22 nov 2012
Microsoft sccm 2012 seminar ddls sydney 22 nov 2012DDLS
 
System Center Endpoint Protection
System Center Endpoint ProtectionSystem Center Endpoint Protection
System Center Endpoint ProtectionScientia Groups
 
2011 11-28 sccm-2012_technical_overview
2011 11-28 sccm-2012_technical_overview2011 11-28 sccm-2012_technical_overview
2011 11-28 sccm-2012_technical_overviewfannaq786
 
Arun SCCM Profile
Arun SCCM Profile Arun SCCM Profile
Arun SCCM Profile Arun M
 
Sccm hands-on-lab
Sccm hands-on-labSccm hands-on-lab
Sccm hands-on-labDPA
 
Microsoft System Center Configuration Manager 2012 R2 Installation
Microsoft System Center Configuration Manager 2012 R2 InstallationMicrosoft System Center Configuration Manager 2012 R2 Installation
Microsoft System Center Configuration Manager 2012 R2 InstallationShahab Al Yamin Chawdhury
 

Viewers also liked (20)

Power shell training
Power shell trainingPower shell training
Power shell training
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShell
 
Professional Help for PowerShell Modules
Professional Help for PowerShell ModulesProfessional Help for PowerShell Modules
Professional Help for PowerShell Modules
 
PowerShell DSC と連携して監視を効率化してみる
PowerShell DSC と連携して監視を効率化してみるPowerShell DSC と連携して監視を効率化してみる
PowerShell DSC と連携して監視を効率化してみる
 
System Center Configuration Manager 2012 Sneak Peek
System Center Configuration Manager 2012 Sneak PeekSystem Center Configuration Manager 2012 Sneak Peek
System Center Configuration Manager 2012 Sneak Peek
 
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...
Using SCUP (System Center Updates Publisher) to Security Patch 3rd Party Apps...
 
What's New in System Center 2012
What's New in System Center 2012 What's New in System Center 2012
What's New in System Center 2012
 
System Center 2012 R2 - Enterprise Automation
System Center 2012 R2 - Enterprise AutomationSystem Center 2012 R2 - Enterprise Automation
System Center 2012 R2 - Enterprise Automation
 
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012
ITCamp 2011 - Adrian Stoian - System Center Configuration Manager 2012
 
Microsoft system center 2012 r2 configuration manager
Microsoft system center 2012 r2 configuration managerMicrosoft system center 2012 r2 configuration manager
Microsoft system center 2012 r2 configuration manager
 
Ultima 14th March
Ultima 14th MarchUltima 14th March
Ultima 14th March
 
World Population Datasheet 2008
World Population Datasheet 2008World Population Datasheet 2008
World Population Datasheet 2008
 
TFS Administration Overview
TFS Administration OverviewTFS Administration Overview
TFS Administration Overview
 
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...
IT/Dev Connections: Intune, ConfigMgr, or Both: Choose the Right Tool for the...
 
Microsoft sccm 2012 seminar ddls sydney 22 nov 2012
Microsoft sccm 2012 seminar   ddls sydney 22 nov 2012Microsoft sccm 2012 seminar   ddls sydney 22 nov 2012
Microsoft sccm 2012 seminar ddls sydney 22 nov 2012
 
System Center Endpoint Protection
System Center Endpoint ProtectionSystem Center Endpoint Protection
System Center Endpoint Protection
 
2011 11-28 sccm-2012_technical_overview
2011 11-28 sccm-2012_technical_overview2011 11-28 sccm-2012_technical_overview
2011 11-28 sccm-2012_technical_overview
 
Arun SCCM Profile
Arun SCCM Profile Arun SCCM Profile
Arun SCCM Profile
 
Sccm hands-on-lab
Sccm hands-on-labSccm hands-on-lab
Sccm hands-on-lab
 
Microsoft System Center Configuration Manager 2012 R2 Installation
Microsoft System Center Configuration Manager 2012 R2 InstallationMicrosoft System Center Configuration Manager 2012 R2 Installation
Microsoft System Center Configuration Manager 2012 R2 Installation
 

Similar to Powershell Training

PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)Concentrated Technology
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellPhan Hien
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2Bryan Cafferky
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101Thomas Lee
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
Sunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil Phani
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Eviljaredhaight
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingRavikanth Chaganti
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidMatthew Johnson
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphonyBrahampal Singh
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopersBryan Cafferky
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answerssheibansari
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdfhamzadamani7
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionDave Diehl
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 

Similar to Powershell Training (20)

PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)PowerShell Core Skills (TechMentor Fall 2011)
PowerShell Core Skills (TechMentor Fall 2011)
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
 
No-script PowerShell v2
No-script PowerShell v2No-script PowerShell v2
No-script PowerShell v2
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
Sunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil phani's take on windows powershell
Sunil phani's take on windows powershell
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell Scripting
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answers
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 

Powershell Training

  • 1. Welcome to PowerShell Training Name : Pardha Sai (Pardhu) Role : Automation Engineer Course Duration : 10 Hours
  • 2. Agenda • What do you know about PowerShell ? • How Powershell help’s IT ? • Little History of Powershell • Variables • Data Types • Conditions • Loops • What is command let ? • How to find Cmdlets in PowerShell ? • 3 important Cmdlets • What is alias ? • What is Pipeline and use of where and select object ? • What is PowerShell profile and how it is used ? • What is WMI Object ?
  • 3. Agenda • What is PowerShell Remoting and How we can remote ? • What is function ? • What is module ? • How to find and use Modules ? • What is RSAT ? • Client VS Server RSAT ? • Getting Started with AD PS Module ? • AD Module Version History • How to import & export CSV data in PS ? • How to Create Bulk User’s by using CSV File ? • How to copy a user across AD? • What is Execution Policy ? • How to build PowerShell Script ?
  • 4. What do you know about PowerShell ??? How Powershell helpful to IT Administrators ??? &
  • 5. History of powershell Jeffrey Snover He is a Distinguished Engineer and the Lead Architect for the Windows Server Division at Microsoft. He is the inventor of Windows PowerShell, an object-based distributed automation engine, scripting language, and command line shell.
  • 6. Version of PowerShell PowerShell V1.0 PowerShell V2.0 PowerShell V3.0 PowerShell V4.0 PowerShell V5.0 • Released in November 2006. • Supports in Windows XP SP2,Vista,2003. • optional component of Windows Server 2008. • Supports in Windows 7,2008 R2. • Also released for Windows XP SP3,2003 SP2 and Vista SP1. • PowerShell Remoting • Modules Supports • Windows PowerShell Integrated Scripting Environment (ISE) • Exception Handling Supports • APIs Supports • New Cmdlets • Supports in Windows 8,2012. • Also released for win 7 SP1,2008 SP1 and 2008 R2 SP1. • Help update (Man Pages) • Automatic module detection • Session connectivity • New Cmdlets and Modules • Supports in Windows 8.1,2012 R2 • Also released for win 7 SP1,2008 R2 SP1 and 2012 R2 SP1. • Desired State Configuration • New Default Execution Policy • Enhanced debugging • workflow PowerShell • New Cmdlets and Modules • Supports in Windows 10,2016 and Nano server • Also released for win 7,8,8.1 SP1,2008 R2 SP1 and 2012 R2 SP1. • Oneget/PowerShell get • PowerShell class definitions (properties, methods) • Desired State Configuration V2.0 • New Cmdlets and Modules @source : Wikipedia
  • 8. Variables Variables store information temporarily so you can take the information contained in a variable and process it in further steps. PowerShell creates new variables automatically so there is no need to specifically "declare" variables. Simply assign data to a variable. The only thing you need to know is that variable names are always prefixed with a "$". You can then output the variable content by entering the variable name, or you can merge the variable content into text strings. To do that, just make sure the string is delimited by double-quotes. Single-quoted text will not resolve variables.
  • 9. • Declare Variables • Selecting Variable Names • Assigning and Returning Values • Using Special Variable Cmdlets • Default Variables Variables
  • 10. What is Data Types ???
  • 11. Data Types There is an additional and important reason to assign data types manually because every data type has its own set of special commands. For example, a date can be stored as text in a String data type. And that's just exactly what PowerShell does: it's not clever enough to automatically guess that this really is a date or time: $date = "November 12, 2004“;$date November 12, 2004 If you store a date as String, then you'll have no access to special date functions. Only DateTime objects make them available. So, if you're working with date and time indicators, it's better to store them explicitly as DateTime: [datetime]$date = "November 12, 2004" $date Friday, November 12, 2004 00:00:00 The output of the variable will now immediately tell you the day of the week corresponding to the date, and also enable comprehensive date and time calculation commands. That makes it easy, for example, to find the date 60 days later: $date.AddDays(60) Tuesday, January 11, 2005 00:00:00
  • 14. Conditions • If Condition • if-Else Condition • If-ElseIf-Else Condition • Switch Condition #Example : If-elseif-else Condition $value = 1 If ($value -eq 1) { " Number 1" } ElseIf ($value -eq 2) { " Number 2" } ElseIf ($value -eq 3) { " Number 3" } else { " Number does not exists" } #Example : Switch Condition $value = 6 Switch ($value) { 1 { "Number 1“ } 2 { "Number 2“ } 3 { "Number 3“ } default { "Number does not exists" } }
  • 16. Loops • For Loop • While Loop • Do While loop • For Each loop • Switch Loop #Example : For Loop For ($i = 0 ;$i -lt 5;$i++) { $i } #Example : While Loop $i = 0 While ($i -lt 5) { $i++ $i } #Example : Do While Loop $i = 0 Do { $i++ $i } While ($i -lt 5) #Example : For Each Loop $array = 1..5 Foreach ($element in $array) { "Current element: $element" } #Example : Switch Loop $array = 1..5 Switch ($array) { Default { "Current element: $_" } }
  • 17. Break..Continue • Break • Continue #Example : For Loop with break and continue For ($i=1; $i -lt 5; $i++) { $password = Read-Host "Enter password ($i. try)" If ($password -eq "secret") { break } if ($password -ne "secret") { continue } }
  • 19. What is Cmdlet ? Cmdlet Function Get-Location get the current directory Set-Location change the current directory Copy-Item copy files Remove-Item remove a file or directory Move-Item move a file Rename-Item rename a file New-Item create a new empty file or directory A cmdlet (pronounced "command-let") is a lightweight Windows PowerShell script that performs a single function. A command, in this context, is a specific order from a user to the computer's operating system or to an application to perform a service, such as "Show me all my files" or "Run this program for me." Although Windows PowerShell includes more than two hundred basic core cmdlets, administrators can also write their own cmdlets and share them.
  • 20. How to find cmdlets in PowerShell ??? The folks at Microsoft made several design strategies when designing PowerShell cmdlets. First is the ability to easily infer cmdlet names, or at the very least make them easy to discover. PowerShell cmdlets are also designed to be easy to use with standardized syntax, making them easy to use interactively from the command line or to create powerful scripts. PowerShell cmdlets use the Verb-Noun format Example : Cmdlet Name Verb Noun Get-Service Get Service Start-Service Start Service The verb portion of the cmdlet name indicates the action to be performed on the noun.
  • 21. Three Important Cmdlets If you don’t remember anything else Get-Help : PowerShell has help info backed right in, Just like “Man” pages in Unix Get-Member : Since PowerShell is object aware, This cmdlet helps explore the methods and Properties within PowerShell Get-Command : PowerShell’s dictionary lookup, this will help you to find cmdlets you can use
  • 22. What is alias ??? An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any Windows PowerShell commands. PowerShell (Cmdlet) PowerShell (Alias) CMD.EXE / COMMAND.COM Unix shell Description Get-ChildItem gci, dir, ls dir ls List all files / directories in the (current) directory Test-Connection/ping N/A ping ping Sends ICMP echo requests to specified machine from the current machine, or instructs another machine to do so Get-Content gc, type, cat type cat Get the content of a file Get-Command gcm help type, which, compgen List available commands Get-Help help, man help apropos, man Help on commands Clear-Host cls, clear cls clear Clear the screen[b] Copy-Item cpi, copy, cp copy cp Copy one or several files / a whole directory tree Move-Item mi, move, mv move mv Move a file / a directory to a new location Remove-Item ri, del, erase, rmdir, rd, rm del, erase, rmdir, rd rm, rmdir Delete a file / a directory Rename-Item rni, ren, mv ren, rename mv Rename a file / a directory Get-Location gl, cd, pwd cd pwd Display the current directory/present working directory. @source : Wikipedia
  • 23. Pipeline You can use pipelines to send the objects that are output by one command to be used as input to another command for processing. And you can send the output of that command to yet another command. The result is a very powerful command chain or "pipeline" that is comprised of a series of simple commands. Example : Get-Process notepad | stop-process Get-Service | Where-Object {$_.name -Match "win"} Get-Service | Where-Object {$_.name -Match "win"} | select Name A pipeline is a series of commands connected by pipeline operators (|) (ASCII 124) . Each pipeline operator sends the results of the preceding command to the next command.
  • 24. What is PowerShell Profile ???
  • 25. What is WMI ???
  • 26. WMI WMI represents the insides of your computer in the form of classes. WMI provides classes for nearly everything: processor, BIOS, memory, user accounts, services, etc. The name of a class usually consists of the "Win32" prefix. For example, the Win32_Service describes services. Get-WmiObject Win32_BIOS Get-WmiObject Win32_Process -filter 'name = "powershell.exe"‘ [wmi]"Win32_Service.Name='netman'“ Get-WmiObject win32_service | Where-Object {$_.name -eq "netman"} Get-WmiObject win32_computersystem | gm Get-WmiObject win32_computersystem | Select-Object domain
  • 29. Functions Functions are self-defined new commands consisting of general PowerShell building blocks. They have in principle three tasks: • Shorthand: very simple shorthand for commands and immediately give the commands arguments to take along • Combining: functions can make your work easier by combining several steps • Encapsulating and extending: small but highly complex programs consisting of many hundreds of statements and providing entirely new functionalities The basic structure of a function is the same in all three instances: after the Function statement follows the name of the function, and after that the PowerShell code in braces. Example : Shorthand Function myPing { ping localhost } Example : Combining Function NextFreeDrive { For ($x=67; $x -le 90; $x++) { $driveletter = [char]$x + ":" If (!(Test-Path $driveletter)) { $driveletter break } } }
  • 31. Modules A module is a package that contains Windows PowerShell commands, such as cmdlets, providers, functions, workflows, variables, and aliases. People who write commands can use modules to organize their commands and share them with others. People who receive modules can add the commands in the modules to their Windows PowerShell sessions and use them just like the built-in commands. BUILT-IN MODULES : Microsoft.PowerShell.Core Microsoft.PowerShell.Diagnostics Microsoft.PowerShell.Host Microsoft.PowerShell.Management Microsoft.PowerShell.Security Microsoft.PowerShell.Utility Microsoft.WSMan.Management PSScheduledJob PSWorkflow PSWorkflowUtility HOW TO USE A MODULE To use a module, perform the following tasks: 1. Install/Import the module. (This is often done for you.) 2. Find the commands that the module added. 3. Use the commands that the module added.
  • 33. RSAT (Remote Server Administration Tools) RSAT (Remote Server Administration Tools) is a Windows Server component for remote management of other computers also running that operating system. RSAT was introduced in Windows Server 2008 R2. RSAT allows administrators to run snap-ins and tools on a remote computer to manage features, roles and role services. The software includes tools for cluster-aware updating, Group Policy management and Hyper-V management, as well as the Best Practices Analyzer. RSAT runs on Windows 7, Windows 8, Windows Server 2008, Windows Server 2008 R2 and Windows Server 2012.
  • 34. Client RSAT AD VS Server RSAT AD Client Windows 7 Windows Server 2008 R2 Windows 8 Windows Server 2012 Windows 8.1 Windows Server 2012 R2 Server Windows Server 2003 or 2008 AD Management Gateway Service Windows Server 2008 R2 Windows Server 2012 Windows Server 2012 R2 Port 9389 AD Cmdlet Feature Level
  • 35. Getting Started with AD PS Module
  • 36. Active Directory PowerShell History Former Scripting Technologies WMI ADODB CMD utilities ADSI (.NET foundation) PowerShell AD Module 2008 R2 (v1) 76 cmdlets Forest, Domain Users, Groups, Computers, OUs Service Accounts Password Policies Recycle Bin Etc. 2012 (v2) +69 cmdlets Replication Trusts DC Cloning Dynamic Access Control ADDS Deployment Module 2012 R2 (v3) +12 cmdlets Authentication Policies
  • 37. How to import & Export CSV data ???
  • 38. Bulk User Creation using CSV File
  • 39. Copy-aduser * Import the Copy-aduser Function in PowerShell Console * Once Copy-aduser Function Loaded type below command to Execute it Example : copy-aduser -fristName "PowerShell" -LastName "Trainer" -userLogonName "Powershell" -SampleUserName "Pardhu" -password "Test@123" Function is placed in below txt file
  • 40. What is Execution Policy ???
  • 41. Execution Policy • Restricted • AllSigned • RemoteSigned • Unrestricted • Bypass • Undefined Windows PowerShell execution policies let you determine the conditions under which Windows PowerShell loads configuration files and runs scripts. You can set an execution policy for the local computer, for the current user, or for a particular session. You can also use a Group Policy setting to set execution policy for computers and users. Execution policies for the local computer and current user are stored in the registry. You do not need to set execution policies in your Windows PowerShell profile. The execution policy for a particular session is stored only in memory and is lost when the session is closed.
  • 42. How to build Powershell Script ???
  • 43. Thank You To Learn Powershell you have use it more Here are Some reference Links : To Learn More : Use Microsoft Virtual Academy For Practice : Use Microsoft Virtual Labs For Cmdlets : Use TechNet Keep up-to-date : Use https://powershell.org/ Name : Pardha Sai (Pardhu) Role : Automation Engineer Phone : 9885572999 Email ID : Pardhasai.Vadlamudi@in.fujitsu.com

Editor's Notes

  1. In Slide Show mode, click the arrow to enter the PowerPoint Getting Started Center.