Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PowerShell custom properties

1,210 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

PowerShell custom properties

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

×