Starting Microsoft Word with presets

Hello again!

Im working on a script that Pop Ups a form where people fill in some info and after that microsoft Word Opens and in the header and footer of the doc are some of the info that the user submitted. the issue i have is that when adding pagenumbers it only shows page 1, page 2 etc. but i want to have it like : page 1 of 4" is that possible.

I found on internet a workaround like opening a template where i have inserted the page numbers via view->insert → pagenumbers. that works partially. when i use the script to open the template. any additial info i want in the footer overwrites the page numbers (i insert it in the footer on the right).

is there a way to ADD the date and username along with the page numbers or is there in powershell a code to insert it.

$name = "somebody"
$date = get-date

$filePath = "C:\testdoc.docx"

$word = New-Object -comobject word.application
$word.visible = $true
$doc = $$filePath)

$section = $doc.sections.item(1)
$Header = $Section.Headers.Item(1);
$Header.range.Text = "Name:$name "

$Footer = $Section.Footers.Item(1);
$Footer.range.text = "created on $date                     Account:$env:USERNAME"
#$Footer.Range.ParagraphFormat.Alignment = 0

$documentfolder = [Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)
$filename = "$documentfolder\testdocument.docx"