title: Powershell Object Fields in Commands
body: <p>I have the following function:</p>
  
  <pre><code>function CreateImage
  {
      param (
          [string] $version = $(throw "-version is required")
      )
  
      $imageInfo = GetImageParamatersFromPath     
  
      docker image build --tag $imageInfo.FullImageName`:$version --file .\Dockerfile .
  }
  </code></pre>
  
  <p>When I call this it fails (the docker command complains about number of parameters).  </p>
  
  <p>But if I change it so that I don't access <code>$imageInfo.FullImageName</code> in the docker call, it works fine:</p>
  
  <pre><code>function CreateImage
  {
      param (
          [string] $version = $(throw "-version is required")
      )
  
      $imageInfo = GetImageParamatersFromPath
      $imageInfo = $imageInfo.FullImageName       
  
      docker image build --tag $imageInfo`:$version --file .\Dockerfile .
  }
  </code></pre>
  
  <p>So, it seems I am not accessing the <code>FullImageName</code> field correctly in my actual docker command.</p>
  
  <p><strong>What is the correct way to access a field in a PowerShell command?</strong></p>
  
  <p><strong>Additional Info:</strong>
  This may have something to do with the colon before the version.  If I change first function to have the following docker command:</p>
  
  <pre><code>docker image build --tag $imageInfo.FullImageName --file .\Dockerfile .
  </code></pre>
  
  <p>Then it works.  (Though it uses <em>:latest</em> instead of my version (obviously)).</p>
  
  <p>So it may be something with the way the two are interacting.</p>
  
  <p>In light of that, It tried this:</p>
  
  <pre><code>docker image build --tag ${imageInfo}.{FullImageName}`:$version --file .\Dockerfile .
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>docker image build --tag ${imageInfo}.{FullImageName}:$version --file .\Dockerfile .
  </code></pre>
  
  <p>But neither worked.</p>