title: Why does object get destroyed after using it several times?
body: <p>I'm using Get-CMApplication to retrieve an application. The result gets stored to $App. I can use $App several times until I use <code>$Deployment = $App | Get-CMApplicationDeployment</code> to retrieve all deployments that are linked to this application. After this line of code the variable $App is empty.</p>
  
  <p>Instead of using <code>$App | Get-CMApplicationDeployment</code> I could retrieve the original object again like so: <code>Get-CMApplication "MyApp 1.0" | Get-CMApplicationDeployment</code>. But I want to limit the queries to the SCCM server, there is no need to query two times the same.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$App = Get-CMApplication -Name "System Center Configuration Manager Console 5.1902.1085.2600"
  Write-Output "This is the app: $($App.LocalizedDisplayName)"
  $Deployment = $App | Get-CMApplicationDeployment
  $Deployment.Count
  Write-Output "This is the app: $($App.LocalizedDisplayName)"
  if ($null -eq $App) {Write-Output "Yes, it's NULL!"}
  if ($App) {Write-Output "Yes, it's available!"}
  if ($App -eq "") {Write-Output "Yes, it's empty!"}
  $App | Get-Member
  </code></pre>
  
  <p>Cloning the object first and using the clone for Get-CMApplicationDeployment allows me to use $App later in my program.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$AppTemp = $App.PsObject.Copy()
  $Deployment = $AppTemp | Get-CMApplicationDeployment
  </code></pre>
  
  <p>I would expect to be able to use $App all over my program, but it seems that using Get-CMApplicationDeployment kills it. Even Get-Member returns an error: The following exception occurred while retrieving members: "Object reference not set to an instance of an object."
  I don't understand why the object $App gets killed.</p>