I am struggling to get this Powershell code to work below. I would like to rename files as per below.
06.09.2022_15.05. MYUSER 1
If there is multiple files in the folder then be able to increment 06.09.2022_15.05. MYUSER 1 06.09.2022_15.05. MYUSER 2 06.09.2022_15.05. MYUSER 3
below is the code i am using but it is not working (obviously)
$GetUser = [Environment]::UserName
$i = 1
Get-ChildItem *.pdf |
rename-item -NewName {((get-date).ToString("dd.MM.yyyy_HH.mm.")+" "+," "+ $GetUser +,$_.Extension -f $i++ )}
This returns
06.09.2022.15.05. MYUSER
As you can see it doesn't have the incremented number at the end