How to extract data from a Word form using Powershell

Welcome Forums General PowerShell Q&A How to extract data from a Word form using Powershell

Viewing 1 reply thread
  • Author
    Posts
    • #280893
      Participant
      Topics: 3
      Replies: 1
      Points: 36
      Rank: Member

      Using Powershell I would like to extract data from a Network Account Request for New Employee Form (Word format) to  eventually use that extracted data to automate the creation of  new user accounts in Active Directory. The form contains tables, button choices, dropdown menu (including calendar). Any suggestiong to help extracting data?  Would it be easier if I modify the current form or create a new form using Excel for example?

      Thank you

    • #280908
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,988
      Helping Hand
      Rank: Community Hero

      Hi cloc14007,

      While there are many ways to get information out of a Word document, you should be getting a CSV feed from HR. EmployeeId should be mapped to the EmployeeId attribute in Active Directory and then the script would check if an ID exists for that user and then provision or update if necessary. When you using a form, HR is usually sending information to a hiring manager, that is filling out a form and copy and pasting or typing data into the form and that is sent to you. I’m sure there are options on the form to add users to groups, but it would be much better to generate the user from the feed and then process the form pieces. All of this typically leads to misspelled names that generate additional tickets to fix what was requested. I have done a lot of consulting at companies to implement Identity Access Management (IAM), so those are tips from a field pro. To answer your question regarding ways to read the form, I would try XML first just so that you don’t need to have Office or Word installed for the script to work. Office uses a very old sluggish COM object model, so reading it as XML skips dealing with that, but there are links for that as well:

      Read as XML:
      https://stackoverflow.com/questions/20835177/read-the-word-document-conent-without-using-microsoft-office
      Read with COM:
      https://mcpmag.com/articles/2018/05/24/getting-started-word-using-powershell.aspx
      https://community.spiceworks.com/topic/2110669-how-can-i-pull-data-from-a-word-form
      Powershell Modules:
      https://www.powershellgallery.com/packages/WordDoc/1.2.0
      https://www.powershellgallery.com/packages/PSWriteWord/1.0.1

Viewing 1 reply thread
  • You must be logged in to reply to this topic.