PowerShell custom properties

  • 792 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
792
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. WELCOME TO TECH | IMMERSION
    Windows PowerShell and Custom Property Stuff
    Presenter: Don Jones
  • 2. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.
    For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com.
    For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
    This work is copyright ©Concentrated Technology, LLC
  • 3. Customize Data Outputwith Calculated Properties
    What are calculated/custom properties (“columns”)?
    Making the hashtable for a calculated property
    A bevvy of examples
  • 4. What Are They?
    PowerShell has the ability to dynamically extend objects
    Adding a NotePropertylets you attach custom information to an object
    Do this to…
    Create custom displays
    Align pipeline output and input for parameter binding
  • 5. Making the Hashtable
    @{ name='whatever'; expression={$_.whatever}}
    Name can also be Label
    Shorten with “n” (or “l”) and “e” for brevity
    Each @hashtable is an element; include multiple elements in a comma-separated list
  • 6. The Trick
    Within the expression {scriptblock}, $_ is a placeholder for whatever object was piped to Select, FT, or FL
    Use $_.whatever to access properties and methods of that object
    This makes slightly more sense in an example. Coming right up.
  • 7. Use With What?
    Use with…
    Select-Object (Select)
    Format-List (FL)
    Format-Table (FT)
  • 8. Examples, Examples, Examplii
    Calculating free disk percentage
    Performing a second WMI query
    Changing “name” to “computername” for parameter binding
    Fixing columns in a CSV for AD user creation
  • 9. ADVANCED TIME!
    Hashtable also accepts…
    FormatString
    Width
    Alignment (Left, Center, Right)
    FormatString is useful anywhere; the other two only with Format-Table
  • 10. More Examplii
    Making disk space look prettier (commas!)
    Aligning and controlling column width more precisely
    FormatString uses same stuff as –f operator
  • 11. Thank you.
  • 12. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.
    For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com.
    For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
    This work is copyright ©Concentrated Technology, LLC