title: PowerShell: How to only return an [PSCustomObject] not an array with other things in it?
body: <p>I have a cmdlet that returns an <code>[PSCustomObject]</code> .   This is done 2 cmdlets deep.  At every  return it adds another  things and then instead of returning  the <code>[PSCustomObject]</code> it returns an array of 3 items.
  This object has string properties and at every level it adds another leading space to them.</p>
  <p>I just want to return the  <code>[PSCustomObject]</code> no array.  How to do this ?</p>
  <p>The object return from the last cmdlet</p>
  <pre><code>$ident
  LocalTime           UtcTime              Data                             
  ---------           -------              ----                             
  5/6/2021 3:43:35 PM 5/6/2021 10:43:35 PM New-NodeIdentifier  &quot;4&quot;          
  5/6/2021 3:43:35 PM 5/6/2021 10:43:35 PM New-NodeGenerationIdentifier  &quot;4&quot;
  
  $ident.Count
  3
  
  2 method deap , 2 leading spaces 
  &quot;$($ident.String)&quot;
  &quot;  4&quot;
  
  &quot;$($ident[2].String)&quot;
  &quot;4&quot;
  </code></pre>
  <p>The functions</p>
  <pre><code>Function New-NodeIdentifier{
   [CmdletBinding()]
      Param(
          [Parameter(Mandatory)]
          [String]$Identifier,
          [Switch]$NoCmdletEntryOutput
      )
      Begin{}
      
          Process{
  
  
          Start-CmdletEntry &quot;New-NodeIdentifier  `&quot;$($Identifier)`&quot;&quot; -NoCmdletEntryOutput:$NoCmdletEntryOutput
  
          #determin identifyer type 
  
  
          $l = $Identifier.split(&quot;.&quot;)
  
          [double]$OutNumber = $null
          $IsGen = $true
          foreach( $c in $l ) {
              Write-Host $c
              if(-not [double]::TryParse($c,[ref]$OutNumber)) {
                  $IsGen = $false
              }
          }
  
          # create the indentifier 
  
          if($IsGen) {
  
              $ni =  New-NodeGenerationIdentifier -Generation $Identifier
  
              write-host &quot;nni `&quot;$($ni.String)`&quot; type $($ni.GetType())&quot;
  
              return $ni
  
          } else {
  
              $ni  =  New-NodeHwSkuIdentifier -HwSku $Identifier
  
              write-host &quot;nni `&quot;$($ni.String)`&quot; type $($ni.GetType())&quot;
  
              return $ni
          }
  
        
       }
     
     End{}
  }
  
  Function New-NodeGenerationIdentifier{
   [CmdletBinding()]
      Param(
          [Parameter(Mandatory)]
          [String]$Generation,
          [Switch]$NoCmdletEntryOutput
      )
      Begin{}
  
         
      Process{
  
           Start-CmdletEntry &quot;New-NodeGenerationIdentifier  `&quot;$($Generation)`&quot;&quot; -NoCmdletEntryOutput:$NoCmdletEntryOutput
  
           $vmi = [PSCustomObject]@{
                  Generation   =&quot;$($Generation)&quot;
                  Type         ='Generation'
                  String       =&quot;$($Generation)&quot;
                  }
           
           write-host &quot;nngi `&quot;$($vmi.String)`&quot; type $($vmi.GetType())&quot;
  
           return $vmi 
  
       }
     
     End{}
  }
  </code></pre>