title: Powershell mystical error
body: <p>Please help! i'm confused what to do.
  Script split files by content: </p>
  
  <pre><code>$InPC = "C:\Scripts\"
  
  Get-ChildItem $InPC -Filter *.prt | ForEach-Object -Process { 
          $basename= $_.BaseName   
          $m = ( ( Get-Content $_ | Where { $_ | Select-String "---------------------  Instance Type and Transmission --------------" -Quiet } | Measure-Object | ForEach-Object { $_.Count } ) -ge 2) 
          $a=1
          if ($m) {
    Get-Content $_ | % {
  
      If ($_ -match "---------------------  Instance Type and Transmission --------------") {
          $OutputFile = "$basename-$a.prt"
          $a++
      }    
      Add-Content $OutputFile $_
      }
    Remove-Item $_ 
    }
    }
  </code></pre>
  
  <p>Everything is going OK when i'm set-location to C:\Scripts. But in base case it won't work and give next error:</p>
  
  <pre><code>Get-Content : Path not found "C:\Users\a.ulianov\PRTPRT.prt".
  C:\Scripts\2.ps1:23 знак:18
  +         $m = ( ( Get-Content $_ | Where { $_ | Select-String "------------------ ...
  +                  ~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (C:\Users\a.ulianov\PRTPRT.prt:String) [Get-Content], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
  
  Get-Content : Path not found "C:\Users\a.ulianov\test.prt".
  C:\Scripts\2.ps1:23 знак:18
  +         $m = ( ( Get-Content $_ | Where { $_ | Select-String "------------------ ...
  +                  ~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (C:\Users\a.ulianov\test.prt:String) [Get-Content], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
  </code></pre>
  
  <p>it's seems to work with default PS location during excuting. What i might modify in this case?</p>
  
  #
  
  <p>thanks to @Raf @Rynant here is little crooked but working solution:</p>
  
  <pre><code>$InPC = "C:\Scripts"
  Get-ChildItem -Path $InPC -Filter *.prt | ForEach-Object -Process { 
          $basename= $_.BaseName   
          $m = ( ( Get-Content $_.FullName | Where { $_ | Select-String "---------------------  Instance Type and Transmission --------------" -Quiet } | Measure-Object | ForEach-Object { $_.Count } ) -ge 2) 
          $a = 1
          if ($m) {
    Get-Content $_.FullName | % {
  
      If ($_ -match "---------------------  Instance Type and Transmission --------------") {
          $OutputFile = "$InPC\$basename _$a.prt"
          $a++
      }    
      Add-Content $OutputFile $_
      }
    Remove-Item $_.FullName 
    }
    } 
  </code></pre>