title: How can I get all window handles by a process in Powershell?
body: <p>I have this script</p>
  
  <pre><code>Get-Process | Where-Object {$_.MainWindowTitle -like "*total*"}  
  </code></pre>
  
  <p>Which yield this information</p>
  
  <pre><code>Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName                                                                     
  -------  ------    -----      ----- -----   ------     -- -----------                                                                     
      362      23    19432      32744   324     3.86   6880 TotalCmd64                                                                      
  </code></pre>
  
  <p>So I have the Process ID.</p>
  
  <p>The <code>*Total*</code> application has many open windows of its own.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I iterate ( using powershell)  through all its windows ( so I can get their window handle)  ? </p>
  
  <p>NB : What is my goal ? </p>
  
  <p><img src="https://i.stack.imgur.com/bAADe.jpg" alt="enter image description here"> : </p>
  
  <p>Looking (for example ) at Visual studio : I have the application running.<br>
  but the application has its own open window .</p>
  
  <p>I want the sub window to be TOPMOsT. I <em>already have</em> the script to make a window topmost. but I need its handle number.</p>