title: Method invocation failed because [System.IO.DirectoryInfo] does not contain a method named 'replace'
body: <p>I have a few hundred folders to represent all my subnets. </p>
  
  <p>Example, for the folder name</p>
  
  <blockquote>
    <p>172.31.3.250_29 </p>
  </blockquote>
  
  <p>represents the subnet</p>
  
  <blockquote>
    <p>172.31.3.250/29</p>
  </blockquote>
  
  <p>Because you can't have "/" in windows folder names.</p>
  
  <p>I have about 250 of these folders.</p>
  
  <p>I am writing a powershell script that will take each folder name and run a script against the "subnet" that the folder represents, and dump a log in that folder.</p>
  
  <p>However, I'm stuck on a simple issue.</p>
  
  <p>I have successfully been able to extract the name of all sub folders in a folder</p>
  
  <p>I need to replace the "_" with "/" to denote proper subnet format for my script. </p>
  
  <pre><code>$NmapFolder = Get-ChildItem -Path "U:\nmap reports\Nmap Subnet Scans\August2019" -Recurse -Directory -Force -ErrorAction SilentlyContinue
  
  $data = ForEach ($items in $NmapFolder){
      $items = $items.replace('_','/')
      #eventually will have nmap script logic
      #eventually will have "wait for nmap done" check before proceeding with next folder/subnet
      write-host $items
  }
  </code></pre>
  
  <p>Which produces the error...</p>
  
  <pre><code>Method invocation failed because [System.IO.DirectoryInfo] does not contain a method named 'replace'.
  At line:6 char:1
  + $items = $items.replace('_','/')
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : MethodNotFound
  </code></pre>