{"id":6612,"date":"2019-03-29T10:03:36","date_gmt":"2019-03-29T14:03:36","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=6612"},"modified":"2019-03-29T10:03:42","modified_gmt":"2019-03-29T14:03:42","slug":"more-fun-with-docker-containers-and-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/","title":{"rendered":"More Fun with Docker Containers and PowerShell"},"content":{"rendered":"<p>A few days ago I shared some experiences of <a title=\"check out the article in case you missed it\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/6586\/powershell-remoting-sessions-and-containers\/\" target=\"_blank\" rel=\"blank noopener noreferrer\">working with Docker containers and PowerShell<\/a>. As I continue to learn Docker, I am also learning how to manage it with PowerShell. The Docker command line tools are fine but I think they are even better when drizzled with a nice PowerShell glaze. Here's a bit more of what I have been working on.<\/p>\n<p><!--more--><\/p>\n<h2>Container ID<\/h2>\n<p>In my previous work, I needed the full container ID so I could use it with the PowerShell PSSession cmdlets. Thanks to people like Tim Pringle, who provided tips on better using the Docker CLI, specifically the filter option.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls -f Name=srv4\n<\/pre>\n<p>The -f could also be written as --filter.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"filtering docker containers\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.png\" alt=\"filtering docker containers\" width=\"1028\" height=\"95\" border=\"0\" \/><\/a><\/p>\n<p>Be careful. Container names are case-sensitive.<\/p>\n<p>With this, I can combine it with a few other parameters to get the full configuration ID.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls --no-trunc -qf Name=srv4\n<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"getting a single id\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-12.png\" alt=\"getting a single id\" width=\"1028\" height=\"93\" border=\"0\" \/><\/a><\/p>\n<h2>Formatting Containers<\/h2>\n<p>It gets better. After a bit of research and experimentation, I figured out how to take advantage of the --format parameter in the Docker CLI.\u00a0 This is meant to show you what formatting options are available to you using the JSON format.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls --no-trunc --format \"{{json .}}\"\n<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Docker container as json\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-13.png\" alt=\"Docker container as json\" width=\"1028\" height=\"162\" border=\"0\" \/><\/a><\/p>\n<p>You can format using any heading preceded by a colon. In other words, you can tell Docker what properties to return from the JSON output.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls -a --no-trunc --format \"{{json .Names}},{{json .ID}},{{json .Image}},{{json .Networks}},{{json .Mounts}},{{json .CreatedAt}}\"\n<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Selected properties\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-14.png\" alt=\"Selected properties\" width=\"1028\" height=\"121\" border=\"0\" \/><\/a><\/p>\n<p>Hey! That is a CSV output. I can use PowerShell to turn that into objects.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls -a --no-trunc --format \"{{json .Names}},{{json .ID}},{{json .Image}},{{json .Networks}},{{json .Mounts}},{{json .CreatedAt}}\" |\nConvertFrom-CSV -Header \"Name\",\"ID\",\"Image\",\"Network\",\"Mounts\",\"Created\"<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Docker containers to PowerShell objects\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-15.png\" alt=\"Docker containers to PowerShell objects\" width=\"1028\" height=\"444\" border=\"0\" \/><\/a><\/p>\n<p>That is very useful, so why not take everything? I know Docker will provide JSON output which means I can convert it and then tweak a few properties to be the of the proper type.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">docker container ls -a --no-trunc --format \"{{json .}}\" | convertfrom-json |\nSelect-Object ID,@{Name=\"Name\";Expression = {$_.names}},Image,\n@{Name=\"Created\";Expression = {($_.createdat -split \"\\s[-+]\\d{4}.*\")[0] -as [datetime]}},\nNetworks,Mounts\n<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Docker PowerShell container objects\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-16.png\" alt=\"Docker PowerShell container objects\" width=\"1028\" height=\"602\" border=\"0\" \/><\/a><\/p>\n<p>In case you're wondering I'm using a regular expression pattern to parse the CreatedAt value to that I can convert it to a proper DateTime object.<\/p>\n<h2>Digging Deeper<\/h2>\n<p>You know me. I always want to discover how far I can go. The Docker CLI has an option to inspect a container. This allows you to get all the information about a given container. The default output is a JSON document. This means I can get all container names and then inspect each one, converting the JSON output to objects in PowerShell.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$c = docker container ls -a --no-trunc --format \"{{json .Names}}\" | \nforeach-object { docker container inspect $_ | ConvertFrom-Json }\n<\/pre>\n<p>I get output like this:<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Sample json output\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-17.png\" alt=\"Sample json output\" width=\"1028\" height=\"519\" border=\"0\" \/><\/a><\/p>\n<p>With a bit of scripting, I can turn this into something a bit more manageable.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">foreach ($item in $c) {\n    $item | Select-object Id,\n    @{Name=\"Name\";Expression = {$_.Name.substring(1)}},\n    @{Name=\"State\";Expression = {$_.state.status}},\n    @{Name=\"IsRunning\";Expression = {$_.state.Running}},\n    @{Name=\"Started\";Expression = {$_.state.startedat -as [datetime]}},\n    @{Name=\"Finished\";Expression = {\n       #this value shows the last time it finished which won't be accurate if\n       #the container is running\n       if ($_.state.running) {\n          $null\n       }\n       else {\n     $_.state.finishedat -as [datetime]\n     }\n     }},\n    @{Name=\"Runtime\";Expression = { \n    if ($_.state.running) { \n     (Get-Date) - ($_.state.startedat -as [datetime])\n    } \n    else {\n        ($_.state.finishedat -as [datetime]) - ($_.state.startedat -as [datetime])\n    }\n    }},\n    Platform,Mounts,\n    @{Name=\"Image\";Expression = { (docker image inspect ($_.image -split \":\")[1] --format \"{{json .RepoTags}}\") -replace '\\[|\\]|\"',\"\" }},\n    @{Name=\"Created\";Expression ={$_.Created -as [datetime]}}\n}\n<\/pre>\n<p>I can even add my own properties.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"my custom container object\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-18.png\" alt=\"my custom container object\" width=\"1028\" height=\"212\" border=\"0\" \/><\/a><\/p>\n<h2>Toolmaking Time<\/h2>\n<p>Obviously, nobody wants to type that all the time. So I turned the code into a proper PowerShell function.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/jdhitsolutions\/a55db2737d30fcb57d4d8c15d47a9cda.js\"><\/script><\/p>\n<p>The function is using a nested PowerShell class to define my custom object.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Getting my custom container objects in PowerShell\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-19.png\" alt=\"Getting my custom container objects in PowerShell\" width=\"1028\" height=\"530\" border=\"0\" \/><\/a><\/p>\n<p>I'm glad I have all of this information available, but part of PowerShell toolmaking is to take how it will be used into account. I wanted a different default view of the objects. This meant I needed a custom format ps1xml file. Fortunately, that is is easy now using the <a title=\"read the online help\" href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\/blob\/master\/docs\/New-PSFormatXML.md\" target=\"_blank\" rel=\"blank noopener noreferrer\">New-PSFormatXML<\/a> command in my <a title=\"check out the project's repository on GitHub\" href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\" target=\"_blank\" rel=\"https:\/\/github.com\/jdhitsolutions\/psscripttools noopener noreferrer\">PSScriptTools<\/a> module.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-DockerContainer | Select -first 1 | New-PSFormatXML -Properties ID,Name,Image,State,IsRunning,Created,Started,Finished,Runtime -Path c:\\scripts\\mydockercontainer.format.ps1xml\n<\/pre>\n<p>I edited the file to get the desired output.<\/p>\n<pre class=\"lang:xml mark:0 decode:true\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;!--\nformat type data generated 03\/27\/2019 17:01:10\nby BOVINE320\\Jeff\n--&gt;\n&lt;Configuration&gt;\n  &lt;ViewDefinitions&gt;\n    &lt;View&gt;\n      &lt;!--Created 03\/27\/2019 17:01:10 by BOVINE320\\Jeff--&gt;\n      &lt;Name&gt;default&lt;\/Name&gt;\n      &lt;ViewSelectedBy&gt;\n        &lt;TypeName&gt;Get-DockerContainer.myDockerContainer&lt;\/TypeName&gt;\n      &lt;\/ViewSelectedBy&gt;\n            &lt;GroupBy&gt;\n               &lt;ScriptBlock&gt;@\"\n$($_.ID)\n   Image Tag   : $($_.image)\n\"@&lt;\/ScriptBlock&gt;\n               &lt;Label&gt;Container ID&lt;\/Label&gt;\n       &lt;\/GroupBy&gt;\n      &lt;TableControl&gt;\n        &lt;TableHeaders&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;Name&lt;\/Label&gt;\n            &lt;Width&gt;7&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;Created&lt;\/Label&gt;\n            &lt;Width&gt;22&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;State&lt;\/Label&gt;\n            &lt;Width&gt;8&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;IsRunning&lt;\/Label&gt;\n            &lt;Width&gt;10&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;Started&lt;\/Label&gt;\n            &lt;Width&gt;21&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;Finished&lt;\/Label&gt;\n            &lt;Width&gt;21&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n          &lt;TableColumnHeader&gt;\n            &lt;Label&gt;Runtime&lt;\/Label&gt;\n            &lt;Width&gt;20&lt;\/Width&gt;\n            &lt;Alignment&gt;left&lt;\/Alignment&gt;\n          &lt;\/TableColumnHeader&gt;\n        &lt;\/TableHeaders&gt;\n        &lt;TableRowEntries&gt;\n          &lt;TableRowEntry&gt;\n            &lt;TableColumnItems&gt;\n               &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;Name&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;Created&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;State&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;IsRunning&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;Started&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;Finished&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n              &lt;TableColumnItem&gt;\n                &lt;PropertyName&gt;Runtime&lt;\/PropertyName&gt;\n              &lt;\/TableColumnItem&gt;\n            &lt;\/TableColumnItems&gt;\n          &lt;\/TableRowEntry&gt;\n        &lt;\/TableRowEntries&gt;\n      &lt;\/TableControl&gt;\n    &lt;\/View&gt;\n  &lt;\/ViewDefinitions&gt;\n&lt;\/Configuration&gt;\n<\/pre>\n<p>Before it can be used, it needs to be imported into the PowerShell session.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Update-FormatData C:\\scripts\\mydockercontainer.format.ps1xml<\/pre>\n<p>Now I get a formatted output that is easier to digest.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-20.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Formatted Docker containers objects in PowerShell\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-20.png\" alt=\"Formatted Docker containers objects in PowerShell\" width=\"1028\" height=\"530\" border=\"0\" \/><\/a><\/p>\n<p>The other properties are still available if I need them.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image-21.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Selecting custom PowerShell Docker container properties\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-21.png\" alt=\"Selecting custom PowerShell Docker container properties\" width=\"1028\" height=\"149\" border=\"0\" \/><\/a><\/p>\n<p>I can already think of more that I want to do with this. Hopefully, you have some ideas as well. And now that I know how to get data from Docker using JSON, there is much, much more that I can do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days ago I shared some experiences of working with Docker containers and PowerShell. As I continue to learn Docker, I am also learning how to manage it with PowerShell. The Docker command line tools are fine but I think they are even better when drizzled with a nice PowerShell glaze. Here&#8217;s a bit&#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":"New from The Lonely Administrator: More Fun with #Docker Containers and #PowerShell","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":[600,4],"tags":[516,601,240,534,540],"class_list":["post-6612","post","type-post","status-publish","format-standard","hentry","category-docker","category-powershell","tag-classes","tag-containers","tag-formatting","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn&#039;t take much to bring it into PowerShell.\" \/>\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\/6612\/more-fun-with-docker-containers-and-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn&#039;t take much to bring it into PowerShell.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-29T14:03:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-29T14:03:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"More Fun with Docker Containers and PowerShell\",\"datePublished\":\"2019-03-29T14:03:36+00:00\",\"dateModified\":\"2019-03-29T14:03:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/\"},\"wordCount\":560,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/image_thumb-11.png\",\"keywords\":[\"Classes\",\"Containers\",\"formatting\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Docker\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/\",\"name\":\"More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/image_thumb-11.png\",\"datePublished\":\"2019-03-29T14:03:36+00:00\",\"dateModified\":\"2019-03-29T14:03:42+00:00\",\"description\":\"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn't take much to bring it into PowerShell.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/image_thumb-11.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/image_thumb-11.png\",\"width\":1028,\"height\":95},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/6612\\\/more-fun-with-docker-containers-and-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Docker\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/docker\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"More Fun with Docker Containers and PowerShell\"}]},{\"@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":"More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator","description":"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn't take much to bring it into PowerShell.","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\/6612\/more-fun-with-docker-containers-and-powershell\/","og_locale":"en_US","og_type":"article","og_title":"More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator","og_description":"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn't take much to bring it into PowerShell.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2019-03-29T14:03:36+00:00","article_modified_time":"2019-03-29T14:03:42+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"More Fun with Docker Containers and PowerShell","datePublished":"2019-03-29T14:03:36+00:00","dateModified":"2019-03-29T14:03:42+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/"},"wordCount":560,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.png","keywords":["Classes","Containers","formatting","PowerShell","Scripting"],"articleSection":["Docker","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/","name":"More Fun with Docker Containers and PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.png","datePublished":"2019-03-29T14:03:36+00:00","dateModified":"2019-03-29T14:03:42+00:00","description":"Learn more about integrating Docker containers into PowerShell. The Docker CLI is a good place to start but it doesn't take much to bring it into PowerShell.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-11.png","width":1028,"height":95},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6612\/more-fun-with-docker-containers-and-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Docker","item":"https:\/\/jdhitsolutions.com\/blog\/category\/docker\/"},{"@type":"ListItem","position":2,"name":"More Fun with Docker Containers and PowerShell"}]},{"@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":6629,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6629\/extending-powershell-and-docker-containers\/","url_meta":{"origin":6612,"position":0},"title":"Extending PowerShell and Docker Containers","author":"Jeffery Hicks","date":"April 2, 2019","format":false,"excerpt":"I've been continuing to tinker with my PowerShell command for getting information about Docker containers. The Docker CLI is fine, but it is very difficult to work with the output or do much with it. That's why I prefer to have objects in a PowerShell pipeline. One of the Docker\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/jdhitsolutions.com\/blog\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":6586,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6586\/powershell-remoting-sessions-and-containers\/","url_meta":{"origin":6612,"position":1},"title":"PowerShell Remoting Sessions and Containers","author":"Jeffery Hicks","date":"March 26, 2019","format":false,"excerpt":"This year I've been ramping up my work with containers via the Docker Desktop application. When Windows Server 2016 was in preview Microsoft tried out some PowerShell cmdlets for working with containers but they never went anywhere. Essentially, the docker command line has become the defacto management tool. There are\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/jdhitsolutions.com\/blog\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-8.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-8.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-8.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/03\/image_thumb-8.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":6751,"url":"https:\/\/jdhitsolutions.com\/blog\/training\/6751\/get-a-jump-start-on-docker\/","url_meta":{"origin":6612,"position":2},"title":"Get a Jump Start on Docker","author":"Jeffery Hicks","date":"June 5, 2019","format":false,"excerpt":"Over the last few years, perhaps no topic has caught fire as much as Docker and containers. If you're like me you've perhaps installed Docker for Windows, pulled down a Windows server image and tinkered a bit with it. Of course, there is so much more to learn and do\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/jdhitsolutions.com\/blog\/category\/docker\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8871,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8871\/more-colorful-fun-with-powershell\/","url_meta":{"origin":6612,"position":3},"title":"More Colorful Fun with PowerShell","author":"Jeffery Hicks","date":"February 14, 2022","format":false,"excerpt":"In my last Friday Fun post, I shared some PowerShell code for displaying [System.Drawing.Color] values from a console using ANSI escape sequences. After I published the article, I realized what I really wanted was a color palette display that wouldn't be affected by the console background. A Windows Presentation Foundation\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/02\/textbox-background.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8173,"url":"https:\/\/jdhitsolutions.com\/blog\/active-directory\/8173\/climbing-trees-in-powershell\/","url_meta":{"origin":6612,"position":4},"title":"Climbing Trees in PowerShell","author":"Jeffery Hicks","date":"February 15, 2021","format":false,"excerpt":"I'm continuing with my renewed interest in Active Directory, and how I can take advantage of PowerShell. This is a topic I've been working with since the PowerShell v2 days. I have a lot of old code. Some of which I've decided to dust off and polish up. One topic\u2026","rel":"","context":"In &quot;Active Directory&quot;","block_context":{"text":"Active Directory","link":"https:\/\/jdhitsolutions.com\/blog\/category\/active-directory\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/canonical-ou-sort.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/canonical-ou-sort.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/canonical-ou-sort.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/02\/canonical-ou-sort.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8622,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8622\/finding-modified-files-with-powershell\/","url_meta":{"origin":6612,"position":5},"title":"Finding Modified Files with PowerShell","author":"Jeffery Hicks","date":"October 14, 2021","format":false,"excerpt":"Here's another task that I seem to be constantly fiddling with using PowerShell. What files did I work on yesterday? Or what files were modified in the last 48 hours? Obviously, Get-ChildItem is going to be the primary command. It is simple enough to get files based on an extension\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/extension-report.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/extension-report.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/extension-report.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6612","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=6612"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6612\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}