```powershell
$word = new-object -comobject word.application
$app = $word.Application
$app.visible = $false

#Enable macros
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\$($word.Version)\word\Security" -Name AccessVBOM -PropertyType DWORD -Value 1 -Force | Out-Null
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\$($word.Version)\word\Security" -Name VBAWarnings -PropertyType DWORD -Value 1 -Force | Out-Null

#Open word document
$Document=$Word.documents.open($filename)

#Run macros
$app.run("DoEvilStuff")

#Disable macros
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\$($word.Version)\word\Security" -Name AccessVBOM -PropertyType DWORD -Value 0 -Force | Out-Null
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\$($word.Version)\word\Security" -Name VBAWarnings -PropertyType DWORD -Value 0 -Force | Out-Null
```