You need to filter on *.pdf and *.dwf files only and also if the filenames match the criterion of starting with 6 digits followed by a space character. Then you can use regex replacements like this:
Get-ChildItem -Path D:\Test -File | Where-Object { $_.Name -match '^\d{6} .*\.(dwf|pdf)$' } | Rename-Item -NewName { $_.Name -replace '^(\d{6}) ', '${1}000_' -replace '\s+', '_'}
Before:
D:\TEST 123456 text text.dwf 123456 text text.pdf 123456 text text.txt
After:
D:\TEST 123456 text text.txt 123456000_text_text.dwf 123456000_text_text.pdf
Regex details of filename -match:
^ Assert position at the beginning of the string \d Match a single digit 0..9 {6} Exactly 6 times \ Match the character “ ” literally . Match any single character that is not a line break character * Between zero and unlimited times, as many times as possible, giving back as needed (greedy) \. Match the character “.” literally ( Match the regular expression below and capture its match into backreference number 1 Match either the regular expression below (attempting the next alternative only if this one fails) dwf Match the characters “dwf” literally | Or match regular expression number 2 below (the entire group fails if this one fails to match) pdf Match the characters “pdf” literally ) $ Assert position at the end of the string (or before the line break at the end of the string, if any)