Open Word Document from Powershell script
I've created a simple Powershell menu script to launch a few applications with but need to open some word docs as well from this script. I've tried several options and can get word to open but have not been able to get it to open a specific document. Just need the proper code to launch MS word and open a specific word document located on my network share. Any takers??????? :)
October 12th, 2011 9:10pm

You can just specify the path to the Word file and it should open it as long as the file associations are correct.

"\\server\share\path\wordfile.docx"


 

Free Windows Admin Tool Kit Click here and download it now
October 12th, 2011 9:20pm

If the document name or path contains spaces, you need to invoke it like this:

 

& '\\Server1\Docs\Shared Documents\Test Document.docx'

October 12th, 2011 9:36pm

Invoke-Item '\\Server1\Docs\Shared Documents\Test Document.docx'
Start '\\Server1\Docs\Shared Documents\Test Document.docx' -verb  open
start '\\Server1\Docs\Shared Documents\Test Document.docx' -verb print
Free Windows Admin Tool Kit Click here and download it now
October 12th, 2011 10:16pm

Jrv has a good answer.

Invoke-Item is the cmdlet you need, assuming Word is the default program for opening .docx files. I use it's alias ii a billion times a day...hehe. It works on any file types I've ever needed.

ii .\newwebpage.html

ii .\cmdletresults.txt

etc...

October 14th, 2011 3:09am

What about if you have a space in the name?

The invoke-item is working for me except when file name has a space. 

Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2015 1:43pm

What about if you have a space in the name?

The invoke-item is working for me except when file name has a space. 

This works just fine:

PS C:\> Invoke-Item 'C:\Scripts\PowerShell Scripts\Misc Testing\2-2-2015\TEST FILE.docx'

You should start up your own thread instead of appending on to an old, answered thread. Make sure you post exactly what you're running and the full error you re

February 2nd, 2015 1:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics