PowerShell for Admins - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

PowerShell for Admins

Description:

formatString -f $total,$property. Debugging in PowerShell. Debugging and Tracing. Debug ... CmdLet using the Visual Studio Windows PowerShell Templates ... – PowerPoint PPT presentation

Number of Views:2019
Avg rating:3.0/5.0
Slides: 17
Provided by: syman6
Category:

less

Transcript and Presenter's Notes

Title: PowerShell for Admins


1
PowerShell for Admins
http//bp0.blogger.com/_O4XKqIP_aWE/Rsq24YoLl4I/AA
AAAAAAALo/oumPQqLvCnI/s1600-h/PowerShell.jpg
  • IgorShare Consulting (www.igorshare.com/blog)
  • Presenter Igor
    Moochnick

2
What is PowerShell?
  • New Command Prompt?
  • No it is a prompt to .NET framework and
    scripting engine for your applications
  • Commands emit objects (Object piping) great
    feature
  • Bunch of tutorials - http//www.powershellpro.com/
    powershell-tutorial-introduction/powershell-functi
    ons-filters/

3
Discovering PowerShell
  • PowerShell provides a discoverable environment.
    If you dont know something or do not remember
    browse around
  • Most of the commands support wildcards

Get-Help (help) Get-Command (gcm) Get-PSDrive
(gdr) Get-Member (gm)
PS C\gt get-command snapin
4
Commands, functions and scripts
  • Create and execute scripts and functions

Function Add (intx 0, inty 0)
    write-host (x y) PS C\gt Add 10 212
5
Calling into .NET framework
  • Use .NET types in your scripts
  • Call into .NET directly

PS C\gt echo (DateTimeNow)
PS C\gt System.Reflection.Assembly
LoadWithPartialName("System.Windows.Forms"
) PS C\gt System.Windows.Forms.MessageBoxShow(
"Hello)
6
Cmdlet Demo
  • Code
  • build class library
  • Registration
  • Installutil ltsnapin.dllgt
  • Add-PSSnapin ltSnapinNamegt
  • Save settings
  • Export-console consoleSnapshot
  • Execution
  • Debugging
  • PowerShell PSConsoleFile consoleSnapshot.psc1

7
Cmdlets
  • PSSnapin (subclass)
  • Default registers all Cmdlets
  • CustomPSSnapin register specific Cmdlets
  • Parameters and Parameter Sets
  • Begin/End/StopProcessing
  • ProcessRecord
  • WriteObject and WriteError

8
Pipeline object flow
Input
Output
Cmdlet 1
Cmdlet 2
0
1
2
3
ProcessRecord Call
4
5
Object Injection
6
Object Replacement
7
8
9
Object Cancelation
9
Advanced Scripting (PoSH 2.0)
function Get-Total ( Stringproperty (throw
"Property Required"), stringformatString
"Total 1 0" ) Begin total
0 Process total
_.property End formatString
-f total,property
10
Debugging in PowerShell
  • Debugging and Tracing
  • Debug
  • Verbose
  • Error Handling
  • ErrorAction
  • ErrorVariable
  • Conditional
  • Whatif
  • Confirm
  • Pipelines
  • Output your data to a file or other command

11
Providers (and Drives)
  • Types of providers
  • Basic provider
  • Drive provider
  • Item provider
  • Container provider
  • Navigation provider
  • Content provider
  • Property provider
  • Default providers
  • Alias
  • Certificate
  • Environment
  • FileSystem
  • Function
  • Providers
  • Registry
  • Variable

12
PASH PoSH bash(http//pash.sourceforge.net)
  • Announcement of PowerShell open source
    reimplementation
  • public project

13
Pash PowerShell everywhere
14
Conclusion
  • Think outside of the BOX !!!

15
Helpful Links
  • Windows PowerShell Team blog http//blogs.msdn.com
    /PowerShell
  • Windows PowerShell ScriptCenterhttp//www.microso
    ft.com/technet/scriptcenter/hubs/msh.mspx
  • Pash - Public Projecthttp//pash.sourceforge.net
  • E-mail igor_at_igorshare.com
  • Blog http//igorshare.wordpress.com/
  • Home Page http//www.igorshare.com/

16
Blogroll
  • Live PowerShell With Karl Prosser
    (http//karlprosser.com/coder/)
  • The PowerShell Guy (http//thepowershellguy.com/)
  • Creating a Windows PowerShell CmdLet using the
    Visual Studio Windows PowerShell Templates
    (http//blogs.msdn.com/daiken/archive/2007/02/07/c
    reating-a-windows-powershell-cmdlet-using-the-visu
    al-studio-windows-powershell-templates.aspx)
  • PowerTab from The PowerShell Guy
    (http//thepowershellguy.com/blogs/posh/pages/powe
    rtab.aspx)
Write a Comment
User Comments (0)
About PowerShow.com