You can use Get-Child item with recursive option to load all the jpg files and rename it using Rename-item command.
Get-ChildItem -r -path "C:\test" *.jpg | % { if(!$_.PSIsContainer -and $_.Name.Contains('_')) {Rename-item $_.FullName ( $_.BaseName.Split('_')[1] +"p" + $_.Extension) } }