{"id":6492,"date":"2019-02-01T12:32:30","date_gmt":"2019-02-01T17:32:30","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=6492"},"modified":"2019-02-01T12:32:36","modified_gmt":"2019-02-01T17:32:36","slug":"creating-more-git-powershell-tools","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/","title":{"rendered":"Creating More Git PowerShell Tools"},"content":{"rendered":"<p>I have received a tremendous amount of interest in my recent articles on <a title=\"read the previous article if you missed out\" href=\"https:\/\/jdhitsolutions.com\/blog\/?p=6478\" target=\"_blank\" rel=\"blank noopener\">creating a git sizing tool using PowerShell<\/a>. Many of you were savvy enough to realize the journey I was describing was just as important as the destination. With that in mind, I decided to revisit another PowerShell and git-related project that I wrote about last year. I created a PowerShell function to <a title=\"check out the original code and article\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/5974\/get-git-configuration-with-powershell\/\" target=\"_blank\" rel=\"blank noopener\">write an object version of your git configuration<\/a>. That function, which originated as a script, is nothing more than a fancy wrapper around a command like <em>git config --global --list<\/em>. Except that instead of dealing with text I have objects in the pipeline.\u00a0 Anyway, based on some things I learned in the last article and some of the techniques I used, I decided to revisit the code and update it.<\/p>\n<p><!--more--><\/p>\n<h2>Adding a Custom Type<\/h2>\n<p>The essence of the PowerShell function is to run a <em>git config<\/em> command and parse the structured data into an object. The previous function wrote a generic custom object to the pipeline. But I decided to take advantage of the technique where I can define the typename with the object.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">foreach ($line in $data) {\n    $split = $line.split(\"=\")\n    #split the first element again to get the category and name\n    $sub = $split[0].split(\".\")\n    [PSCustomObject]@{\n        PSTypeName   = 'gitConfig'\n        Scope        = $scope\n        Category     = $sub[0]\n        Name         = $sub[1]\n        Setting      = $split[1]\n        Username     = $env:username\n        Computername = $env:COMPUTERNAME\n    }\n} #foreach line\n<\/pre>\n<p>Each line from the git configuration will be turned into a custom object of the type 'gitConfig'. While I was at it, I decided to include additional parameters for the username and computername.\u00a0 Even though the intent is to run the command locally, if the data is serialized or saved to a file it might be helpful to know where it originated. As you build your own PowerShell tools you always need to be thinking about how the results might be used and even <em>where<\/em> they might be consumed.<\/p>\n<h2>Extending the gitConfig Type<\/h2>\n<p>So now I have a custom object with its own type name. By default I'll get all properties. But I don't really want that. By default I don't need to see the Username and Computername properties. The solution, as I did last time, is to define a default property set using <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113421\" target=\"_blank\" rel=\"noopener\">Update-TypeData<\/a>.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Update-TypeData -TypeName 'gitConfig' -DefaultDisplayPropertySet 'Scope', 'Category', 'Name', 'Setting' -force\n<\/pre>\n<p>The additional properties are there if I need them.<\/p>\n<p>Since I created my custom object to be more PowerShell-like it may lose some of its 'git-ness'. For example, in the custom object I am using property names like Category and Setting. But in the git world, these parts of the configuration file are probably more likely referred to as Section and Value. One thing I can do to make the result more git-friendly, is to create alias properties for Category and Setting.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Update-TypeData -TypeName 'gitConfig' -MemberType AliasProperty -MemberName 'Value' -Value 'Setting' -force\nUpdate-TypeData -TypeName 'gitConfig' -MemberType AliasProperty -MemberName 'Section' -Value 'Category' -force\n<\/pre>\n<p>Even the the default display won't use the aliases, although it certainly could, if the user knows the aliases exist they can use them.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Using the custom object aliases\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png\" alt=\"Using the custom object aliases\" width=\"1028\" height=\"377\" border=\"0\" \/><\/a><\/p>\n<p>I also added a custom type extension to show the git version.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Update-TypeData -TypeName 'gitConfig' -MemberType ScriptProperty -MemberName gitVersion -value {git --version} -force\n<\/pre>\n<p><a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113322\" target=\"_blank\" rel=\"noopener\">Get-Member<\/a> displays all of these properties.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Viewing the PowerShell custom object properties and aliases\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-1.png\" alt=\"Viewing the PowerShell custom object properties and aliases\" width=\"1028\" height=\"475\" border=\"0\" \/><\/a><\/p>\n<h2>The PowerShell Code<\/h2>\n<p>I've posted this version of the script on <a title=\"visit the gist page\" href=\"https:\/\/gist.github.com\/jdhitsolutions\/2883df22ca7bb1492802f74545af7736\" target=\"_blank\" rel=\"blank noopener\">GitHub<\/a>.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/jdhitsolutions\/2883df22ca7bb1492802f74545af7736.js\"><\/script><\/p>\n<p>If you look just before the Parameter declaration, you can see that I am defining the output type with my custom type name. If you enclose it in braces like [gitConfig] PowerShell might try to look for a registered type and complain. Use a string. This is all for documentation purposes anyway. I'm also defining an alias, <em>ggc<\/em>, as part of the function. That way I don't have to include code to run <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113390\" target=\"_blank\" rel=\"noopener\">Set-Alias<\/a> or <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113352\" target=\"_blank\" rel=\"noopener\">New-Alias<\/a>.<\/p>\n<p>The other item I want to point out is the use of an internal and private \"helper\" function. This function does not use a standard Verb-Noun name because it is not exposed to the user. This is a block of code that can be called depending on the parameter set. What I don't want are two copies of chunks of code. Not only does that make the code a bit more unwieldy I have to maintain the code in to places.\u00a0 Modularizing with a private function simplifies the process, and if I were building a Pester test, would also be easier to test.<\/p>\n<h2>Getting Git Config the PowerShell Way<\/h2>\n<p>Once I've dot sourced the ps1 file, I have a new command that lets me view my git configuration in any number of ways.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Formatting git configuration as a PowerShell Table\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-2.png\" alt=\"Formatting git configuration as a PowerShell Table\" width=\"1028\" height=\"625\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Getting global git aliases\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-3.png\" alt=\"Getting global git aliases\" width=\"1028\" height=\"264\" border=\"0\" \/><\/a><\/p>\n<p>I realize that you can still use the <em>git<\/em> command line tool to display much of the same information. But when I have this turned into PowerShell, then I can build additional tooling around it like this:<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">#dot source the required function\n. C:\\scripts\\Get-Gitconfig.ps1\n\n$data = Get-GitConfig -Scope Global,System\n$frags = @(\"&lt;H1&gt;Git Configuration&lt;\/H1&gt;\")\n$frags+= $data[0] | Select-object \"Computername\",\"Username\"| ConvertTo-Html -Fragment\n\n$data | Group-Object -Property Scope | ForEach-Object {\n $frags += \"&lt;H2&gt;$($_.name.toupper())&lt;\/H2&gt;\"\n $frags+= $_.group | Sort-Object Category | \n Select-Object -Property Category,Name,Setting | ConvertTo-Html -Fragment\n}\n\n$head = @\"\n&lt;Title&gt; git Configuration&lt;\/Title&gt;\n&lt;style&gt;\nbody { background-color:#FFFFFF;\n       font-family:Monospace;\n       font-size:10pt; }\ntd, th { border:0px solid black; \n         border-collapse:collapse;\n         white-space:pre;\n         font-size:12pt; }\nth { color:white;\n     background-color:black; }\ntable, tr, td, th { padding: 0px; margin: 0px ;white-space:pre; }\ntr:nth-child(odd) {background-color: lightgray}\ntable { margin-left:10px; }\nh2 {\n font-family:Tahoma;\n}\n&lt;\/style&gt;\n\n\"@\n\nConvertTo-Html -Body $frags -Head $head -PostContent \"&lt;h4&gt;$($data[0].gitversion)&lt;\/h4&gt;\"| Out-File mygit.html -Encoding ascii\n<\/pre>\n<p>This will create an html report of my git configuration. If you have git installed, you should be able to run it as well.<\/p>\n<p>I hope found found this journey informative. Although the best way to learn is by doing. I hope you'll grab my code, open them up your scripting editor and see how they work. Give them a spin. Tweak them to see what happens. Have fun. That's how you learn.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have received a tremendous amount of interest in my recent articles on creating a git sizing tool using PowerShell. Many of you were savvy enough to realize the journey I was describing was just as important as the destination. With that in mind, I decided to revisit another PowerShell and git-related project that I&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Just published: Creating More Git #PowerShell Tools","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[521,4,8],"tags":[224,519,534,439],"class_list":["post-6492","post","type-post","status-publish","format-standard","hentry","category-git","category-powershell","category-scripting","tag-function","tag-git","tag-powershell","tag-update-typedata"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating More Git PowerShell Tools &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating More Git PowerShell Tools &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-01T17:32:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-01T17:32:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Creating More Git PowerShell Tools\",\"datePublished\":\"2019-02-01T17:32:30+00:00\",\"dateModified\":\"2019-02-01T17:32:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/\"},\"wordCount\":805,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/image_thumb.png\",\"keywords\":[\"Function\",\"Git\",\"PowerShell\",\"Update-TypeData\"],\"articleSection\":[\"Git\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/\",\"name\":\"Creating More Git PowerShell Tools &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/image_thumb.png\",\"datePublished\":\"2019-02-01T17:32:30+00:00\",\"dateModified\":\"2019-02-01T17:32:36+00:00\",\"description\":\"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/image_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/02\\\/image_thumb.png\",\"width\":1028,\"height\":377},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6492\\\/creating-more-git-powershell-tools\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Git\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/git\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating More Git PowerShell Tools\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating More Git PowerShell Tools &#8226; The Lonely Administrator","description":"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/","og_locale":"en_US","og_type":"article","og_title":"Creating More Git PowerShell Tools &#8226; The Lonely Administrator","og_description":"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/","og_site_name":"The Lonely Administrator","article_published_time":"2019-02-01T17:32:30+00:00","article_modified_time":"2019-02-01T17:32:36+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Creating More Git PowerShell Tools","datePublished":"2019-02-01T17:32:30+00:00","dateModified":"2019-02-01T17:32:36+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/"},"wordCount":805,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png","keywords":["Function","Git","PowerShell","Update-TypeData"],"articleSection":["Git","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/","name":"Creating More Git PowerShell Tools &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png","datePublished":"2019-02-01T17:32:30+00:00","dateModified":"2019-02-01T17:32:36+00:00","description":"I continue my exploration of creating git-based PowerShell tools. Learn how I turn your git configuration file into a re-usable PowerShell object.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/02\/image_thumb.png","width":1028,"height":377},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6492\/creating-more-git-powershell-tools\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Git","item":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},{"@type":"ListItem","position":2,"name":"Creating More Git PowerShell Tools"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4999,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4999\/finding-git-repositories-with-powershell\/","url_meta":{"origin":6492,"position":0},"title":"Finding Git Repositories with PowerShell","author":"Jeffery Hicks","date":"May 18, 2016","format":false,"excerpt":"As part of my ongoing improvement process this year I am starting to use Git much more. Yesterday I posted an article with my PowerShell script to create a new project folder which includes creating a Git repository. My challenge has been that I don't always remember what I have\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"find git repositories with PowerShell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/image_thumb-1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/image_thumb-1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/image_thumb-1.png?resize=525%2C300 1.5x"},"classes":[]},{"id":6465,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6465\/keeping-git-in-check-with-powershell\/","url_meta":{"origin":6492,"position":1},"title":"Keeping Git in Check with PowerShell","author":"Jeffery Hicks","date":"January 28, 2019","format":false,"excerpt":"Last week on Twitter I saw a discussion about a git related problem. The short version of the story is that the person was running out of disk space and didn't understand why. Turns out this person has several development projects using git. All of the change tracking and other\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-26.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5121,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5121\/friday-fun-find-a-git-tip-with-powershell\/","url_meta":{"origin":6492,"position":2},"title":"Friday Fun: Find a Git Tip with PowerShell","author":"Jeffery Hicks","date":"June 24, 2016","format":false,"excerpt":"Recently I published a PowerShell function that I use to display a random Git Tip of the Day. The function relies on my clone of the Git-Tips project on GitHub. I've been keeping tabs on this project and a question was posed about creating a command line utility to search\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"finding a git tip with PowerShell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-20.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-20.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-20.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5132,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5132\/downloading-git-tips-with-powershell\/","url_meta":{"origin":6492,"position":3},"title":"Downloading Git Tips with PowerShell","author":"Jeffery Hicks","date":"June 27, 2016","format":false,"excerpt":"So I've been sharing a number of PowerShell tools I've created for working with Git, including a few for getting tips from the Git Tips project on GitHub. My initial work was based on the fact that I had a local clone of that repository and wanted to search the\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"getting all online git tips with PowerShell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5112,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5112\/creating-git-commit-messages-with-powershell\/","url_meta":{"origin":6492,"position":4},"title":"Creating Git Commit Messages with PowerShell","author":"Jeffery Hicks","date":"June 21, 2016","format":false,"excerpt":"As part of my process of learning an using Git I am trying to get in the habit of using meaningful commit messages. Sure, you can get by with a single line comment which is fine when running git log --oneline. But you can use a multi-line commit message. However,\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-19.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-19.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-19.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5974,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5974\/get-git-configuration-with-powershell\/","url_meta":{"origin":6492,"position":5},"title":"Get Git Configuration with PowerShell","author":"Jeffery Hicks","date":"May 11, 2018","format":false,"excerpt":"A few weeks ago I was teaching a PowerShell fundamentals course. Towards the end of the week we start creating simple scripts and functions. One night after class I was thinking about giving them another example and I was working on a project using git. At some point I was\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/05\/image_thumb-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/05\/image_thumb-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/05\/image_thumb-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/05\/image_thumb-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6492"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6492\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}