0 votes

I have a word document that I need to have the users first and last name added to along with the password. I was wondering if you know of an easy way to capture those variables and pass them to a word document via a Custom Command or Business rule.

Thanks,
Tony

by (480 points)
0

Hello Tony,

That can be done using a PowerShell script. We've asked our script guys to make you a sample. We'll update this topic as soon as they come up with something.

0

Here is what we have come up with, but it is failing at the moment.
"Exception calling "Add" with "1" argument(s):"Word was unable to read this document. It may be corrupt."

If we run the script locally and not through Adaxes it works fine.

Thanks,

Tony

$word = New-Object -ComObject "Word.application"
$word.Visible = $false        
$doc = $word.Documents.Add("C:\temp\EULA.dotx")

#Variables
$fullname = "%fullname%"
$password = "%unicodePwd%"
$emailaddress = "%mail%"
$username = "%username%"

$FindFullname = "Fullname1"
$FindUsername = "username1"
$FindEmail = "emailaddress1"
$FindPassword = "password1"

$ReplaceAll = 2
$FindContinue = 1
$MatchCase = $False
$MatchWholeWord = $True
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $FindContinue
$Format = $False

$selection = $word.Selection

$selection.Find.Execute($FindFullname,$MatchCase,
  $MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
  $MatchAllWordForms,$Forward,$Wrap,$Format,
  $fullname,$ReplaceAll)

$selection.Find.Execute($FindUsername,$MatchCase,
  $MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
  $MatchAllWordForms,$Forward,$Wrap,$Format,
  $username,$ReplaceAll)

$selection.Find.Execute($FindEmail,$MatchCase,
  $MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
  $MatchAllWordForms,$Forward,$Wrap,$Format,
  $emailaddress,$ReplaceAll)

$selection.Find.Execute($FindPassword,$MatchCase,
  $MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
  $MatchAllWordForms,$Forward,$Wrap,$Format,
  $password,$ReplaceAll)

$file = "C:\temp\$username.docx"
$word.ActiveDocument.SaveAs([ref]$file)
$quitFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveOptions],"wdDoNotSaveChanges")
$Word.Quit([ref]$quitformat)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello Tony,

See the following entry in our Script Repository: Save user account properties to a Microsoft Word document.

0

Thank you, that was exactly what we needed :)

Tony

Related questions

0 votes
1 answer

We have a business need for automating and controlling the creation of service accounts in our AD. For example, we want all new service accounts to start with "svc_" for ... customize the "New User" form to create a "New Service Account" workflow in Adaxes?

asked Sep 10, 2021 by joshua.lapchuk (60 points)
0 votes
1 answer

We were wondering if Adaxes has a script available to create AS400 accounts during the AD creation. This will allow us to totally automate the new hire process going forward.

asked Jan 26, 2017 by willy-wally (3.2k points)
0 votes
1 answer

Hi, Was wondering if there's a nice way to manually or automatically check if a username or an extension is in use before creating a user? What do other people do? ... in the results, deleting the user and starting again - but would rather the checks first.

asked Feb 25, 2016 by AdamFowlerIT (120 points)
0 votes
1 answer

All, I was wondering if there is a way to add check boxes that correspond to custom commands. Ie if I as the administrator want to give another user the ability to create ... to specific groups. All this would be avaliable from the new user form. Thanks, Tony

asked Nov 5, 2015 by cyspry (480 points)
0 votes
1 answer

Hi folks, I am looking for suggestions on the best way to create/migrate/remote move our student mailboxes to 365. Until now, I have been creating the new AD accounts and ... a 'remote mailbox' in the contacts container. Let the magic begin.... Thanks Kempy

asked Jan 7, 2015 by ckemp (170 points)
3,588 questions
3,277 answers
8,303 comments
548,090 users