<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[ERICK'S BLOG - Blog & Examples]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples]]></link><description><![CDATA[Blog & Examples]]></description><pubDate>Fri, 11 Sep 2026 01:08:01 -0700</pubDate><generator>Weebly</generator><item><title><![CDATA[Finding Duplicate Files with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/finding-duplicate-files-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/finding-duplicate-files-with-powershell#comments]]></comments><pubDate>Mon, 29 Aug 2016 01:04:27 GMT</pubDate><category><![CDATA[PowerShell]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/finding-duplicate-files-with-powershell</guid><description><![CDATA[ If you are like me, you create a lot of backups. &nbsp;My most common backups are cutting and pasting every recognizable file that I may have created onto an external drive before routinely reinstalling Windows. &nbsp;This often leads to me having many copies of the same file in multiple drives and folders. &nbsp;I needed a way to scan for all duplicate files so that I could finally consolidate my backups into having unique files only.       I decided to create a simple script that would scan t [...] ]]></description><content:encoded><![CDATA[<span class='imgPusher' style='float:left;height:0px'></span><span style='display: table;width:auto;position:relative;float:left;max-width:100%;;clear:left;margin-top:0px;*margin-top:0px'><a><img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/find-duplicates-01_1_orig.png" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:1px;padding:3px; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="text-align:justify;display:block;">If you are like me, you create a lot of backups. &nbsp;My most common backups are cutting and pasting every recognizable file that I may have created onto an external drive before routinely reinstalling Windows. &nbsp;This often leads to me having many copies of the same file in multiple drives and folders. &nbsp;I needed a way to scan for all duplicate files so that I could finally consolidate my backups into having unique files only.<br /></div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph">I decided to create a simple script that would scan two given top level directories and check each file in one directory for a duplicate in the other. &nbsp;If one was found, the names and locations of both files would be written to a csv file that could then be easily read and sorted in Excel.</div>  <div id="617650095247231335"><div><style type="text/css">	#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--light {  padding: 20px 0px;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--light .header .paragraph {  margin: 0;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--dark {  padding: 20px 0px;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--dark .header .paragraph {  margin: 0;}#element-b85b860e-1bf3-4686-8632-f96f16a3e8f7 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-b85b860e-1bf3-4686-8632-f96f16a3e8f7" data-platform-element-id="270170748587580171-1.3.1" class="platform-element-contents">	<div class="code-editor--dark">    <div class="header">        <div class="paragraph">Find_Duplicates.ps1</div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph">When you run the above code, you will get a Log.csv file like below if any duplicates are found.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/find-duplicates-01_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">As you can see from the above example, I have many copies of the same file that even have different names. &nbsp;This would be a nightmare to sort out manually. &nbsp;The script is currently single threaded and will take some time to run on a large dataset. &nbsp;I plan to upgrade it to use multithreading later on and follow up with a secondary script that reads this csv file and either moves or deletes duplicates.</div>]]></content:encoded></item><item><title><![CDATA[How to Convert Any Office File to PDF with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-convert-any-office-document-to-pdf-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-convert-any-office-document-to-pdf-with-powershell#comments]]></comments><pubDate>Fri, 17 Jun 2016 06:21:06 GMT</pubDate><category><![CDATA[Office]]></category><category><![CDATA[PDF]]></category><category><![CDATA[PowerShell]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/how-to-convert-any-office-document-to-pdf-with-powershell</guid><description><![CDATA[In this case, "Any" = Word, Excel, PowerPoint, Publisher, and Visio.Now that that is out of the way, my Doc2PDF script will:Detect whether you have given it a file or directoryConvert that single file or all files in a directory and all subdirectories to PDFsIt is very easy to use. &nbsp;Please leave me feedback if you found it useful. &nbsp;Download from below link.https://github.com/escottj/Doc2PDF [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;">In this case, "Any" = Word, Excel, PowerPoint, Publisher, and Visio.<br /><br />Now that that is out of the way, my Doc2PDF script will:<ul><li>Detect whether you have given it a file or directory</li><li>Convert that single file or all files in a directory and all subdirectories to PDFs</li></ul><br />It is very easy to use. &nbsp;Please leave me feedback if you found it useful. &nbsp;Download from below link.<br /><br /><a href="https://github.com/escottj/Doc2PDF" target="_blank">https://github.com/escottj/Doc2PDF</a><br /></div>]]></content:encoded></item><item><title><![CDATA[How to Add a Cover Page to Word with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-add-a-cover-page-to-word-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-add-a-cover-page-to-word-with-powershell#comments]]></comments><pubDate>Wed, 15 Jun 2016 04:07:44 GMT</pubDate><category><![CDATA[Cover Page]]></category><category><![CDATA[PowerShell]]></category><category><![CDATA[Word]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/how-to-add-a-cover-page-to-word-with-powershell</guid><description><![CDATA[       &#8203;I needed to add a cover page to many documents and decided to automate the process with PowerShell. &nbsp;The real issue was to only add a cover page if one doesn't already exist.      Summary:The below script will open a given document, check if a cover page exists and add one if it doesn'tProblem Overview:Need to detect if a cover page exists and add one if it doesn't.Solution:I decided to create a cover page first by making a separate document that contains just the cover page I [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/5718886_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;">&#8203;I needed to add a cover page to many documents and decided to automate the process with PowerShell. &nbsp;The real issue was to only add a cover page if one doesn't already exist.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><strong>Summary:</strong><br />The below script will open a given document, check if a cover page exists and add one if it doesn't<br /><br /><strong>Problem Overview:</strong><br />Need to detect if a cover page exists and add one if it doesn't.<br /><br /><strong>Solution:</strong><br />I decided to create a cover page first by making a separate document that contains just the cover page I want to add and then combining it with the document that I want to add it to.<br /><br />It is simple enough to create a custom cover page. &nbsp;Combining two documents is not too hard either. &nbsp;Detecting if a cover page already exists is what began to cause me issues.<br /><br />I tried to see if there was any special "cover page only" attributes that got added when you used one of the OOTB templates. &nbsp;All of these templates just appeared to have document controls, shapes, and typical formatting. &nbsp;Nothing stood out initially and I couldn't find any standard method to see if one exists via code.<br /><br />I then noticed that all of the OOTB templates have a content control with a label of "Title". &nbsp;I decided to use that as my search term so my solution outline would become:<ol><li>Open document.</li><li>Search all content controls in document for one that has a title of "Title".</li><li>Add cover page or not.</li></ol><br /><strong>Limitations:</strong><br />I am assuming any cover page that may exist has a content control with a title part named "Title." &nbsp;If you made the cover page yourself, then you may put something else for title so you will need to compensate for that.<br /><br />Even though the OOTB cover pages use such a content control, you may have even added one with the same title somewhere else in a document that doesn't actually have a cover page. &nbsp;Again, you will need to compensate for this as well.<br /><br /><strong>How to Use:</strong><br />Save the script as "WordCoverPage.ps1" and run in either one of two ways:<br />PowerShell:<br />./WordCoverPage&nbsp;&lt;full file location&gt; &lt;full cover page location&gt;<br />Command Prompt:<br />powershell -command "&lt;full script location&gt; &lt;full file location&gt; &lt;full cover page location&gt;"<br /><br /><strong>Tips:</strong><br />Create a ForEach loop to run this on a directory full of files.</div>  <div id="691399531357851913"><div><style type="text/css">	#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--light {  padding: 20px 0px;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--light .header .paragraph {  margin: 0;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--dark {  padding: 20px 0px;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--dark .header .paragraph {  margin: 0;}#element-4caf6787-03e8-4ede-8e56-186a798d73d6 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-4caf6787-03e8-4ede-8e56-186a798d73d6" data-platform-element-id="270170748587580171-1.3.1" class="platform-element-contents">	<div class="code-editor--dark">    <div class="header">        <div class="paragraph" style="text-align:left;">&#8203;WordCoverPage.ps1</div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div class="paragraph" style="text-align:left;"><strong>Search Links:</strong><ul><li>How to Detect if a Cover Page Exists in Word with PowerShell</li><li>How to Change the Value of a Content Control Object in Word with PowerShell</li></ul></div>]]></content:encoded></item><item><title><![CDATA[Excel PowerShell Reference]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/excel-powershell-reference]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/excel-powershell-reference#comments]]></comments><pubDate>Tue, 07 Jun 2016 02:31:15 GMT</pubDate><category><![CDATA[Excel]]></category><category><![CDATA[PowerShell]]></category><category><![CDATA[Reference]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/excel-powershell-reference</guid><description><![CDATA[Hello Internet!I have decided to showcase various snippets of code for working with Excel in PowerShell on its own page here Excel PowerShell Reference. &nbsp;The purpose of this is to give you the power to create your own automation scripts by putting together the various working pieces on that page.This blog will remain the place to go for full working examples of solutions to slightly more complex problems.Happy Scripting! [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;">Hello Internet!<br /><br />I have decided to showcase various snippets of code for working with Excel in PowerShell on its own page here <a href="https://www.erickscottjohnson.com/excel-reference.html">Excel PowerShell Reference</a>. &nbsp;The purpose of this is to give you the power to create your own automation scripts by putting together the various working pieces on that page.<br /><br />This blog will remain the place to go for full working examples of solutions to slightly more complex problems.<br /><br />Happy Scripting!<br /></div>]]></content:encoded></item><item><title><![CDATA[How to Convert Word Documents to PDFs with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-convert-word-documents-to-pdfs-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-convert-word-documents-to-pdfs-with-powershell#comments]]></comments><pubDate>Sun, 05 Jun 2016 23:15:09 GMT</pubDate><category><![CDATA[PDF]]></category><category><![CDATA[PowerShell]]></category><category><![CDATA[Word]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/how-to-convert-word-documents-to-pdfs-with-powershell</guid><description><![CDATA[           I needed a way to generate PDFs of Word documents automatically for a custom Office worker I was making for Windchill. &nbsp;The following script will show you the core code to due such a thing.      Summary:The WordPDF script below automates the task of converting Word readable documents to PDFs.Problem Overview:For my Windchill Document Worker, I needed a way to convert Word documents to PDFs via the command line. &nbsp;Using Word to do this would prevent any kind of format translat [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/8130022_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div class="paragraph" style="text-align:left;">I needed a way to generate PDFs of Word documents automatically for a custom Office worker I was making for Windchill. &nbsp;The following script will show you the core code to due such a thing.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><strong>Summary:</strong><br />The WordPDF script below automates the task of converting Word readable documents to PDFs.<br /><br /><strong>Problem Overview:</strong><br />For my <a href="https://www.erickscottjohnson.com/document-worker.html">Windchill Document Worker</a>, I needed a way to convert Word documents to PDFs via the command line. &nbsp;Using Word to do this would prevent any kind of format translation errors that are often in other free programs that can open Word documents.<br /><br /><strong>Solution:</strong><br />Apparently, this is a very easy thing to do so I will spare you the boring details and let the script speak for itself.<br /><br /><strong>Tips:</strong><br />You can easily add a ForEach loop to go through all documents in a given directory and convert them to PDFs. &nbsp;I didn't need to do such a thing for my purposes as I am only provided a single file at a time so I will leave that little piece up to you to figure out. =)</div>  <div id="780248303949277060"><div><style type="text/css">	#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--light {  padding: 20px 0px;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--light .header .paragraph {  margin: 0;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--dark {  padding: 20px 0px;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--dark .header .paragraph {  margin: 0;}#element-d5e19ca3-43e3-4955-8388-579d50a5a2fa .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-d5e19ca3-43e3-4955-8388-579d50a5a2fa" data-platform-element-id="270170748587580171-1.3.1" class="platform-element-contents">	<div class="code-editor--dark">    <div class="header">        <div class="paragraph" style="text-align:left;">WordPDF.ps1</div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>]]></content:encoded></item><item><title><![CDATA[How to Add a Signature Image to a Word Document with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-add-a-signature-image-to-a-word-document-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-add-a-signature-image-to-a-word-document-with-powershell#comments]]></comments><pubDate>Sun, 05 Jun 2016 21:14:25 GMT</pubDate><category><![CDATA[PowerShell]]></category><category><![CDATA[Signature]]></category><category><![CDATA[Word]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/how-to-add-a-signature-image-to-a-word-document-with-powershell</guid><description><![CDATA[           Adding your signature to digital documents isn't too difficult to do but what if you need to automate the process in a certain PDM/PLM system? &nbsp;This PowerShell script is the snippet of code I used to auto sign documents during Windchill publishing.  June 8, 2016: Updated to 1.1 with auto image resize.      Version History:1.1: Signature auto resize added, June 8, 20161.0:&nbsp;Initial release,&nbsp;June 5, 2016&#8203;Summary:The below script will automate the process of adding a  [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/6996600_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div class="paragraph" style="text-align:left;">Adding your signature to digital documents isn't too difficult to do but what if you need to automate the process in a certain PDM/PLM system? &nbsp;This PowerShell script is the snippet of code I used to auto sign documents during Windchill publishing.</div>  <h2 class="wsite-content-title" style="text-align:left;"><strong><font color="#4caac9">June 8, 2016: Updated to 1.1 with auto image resize.</font></strong></h2>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><strong>Version History:</strong><br /><strong>1.1:</strong> Signature auto resize added, June 8, 2016<br /><strong>1.0:</strong><span>&nbsp;Initial release,&nbsp;June 5, 2016</span><br />&#8203;<br /><strong>Summary:</strong><br />The below script will automate the process of adding a digital signature image to Word documents.<br /><br /><strong>Problem Overview:</strong><br />I needed a way to to automatically add a signature to approved documents when they got published in Windchill. &nbsp;Leaving out the Windchill part for now and making this script a "general use" script, I have trimmed the code to just show the relevant signature part.<br /><br /><strong>Limitations Encountered:</strong><br /><strong>(Fixed in version 1.1.)&nbsp;</strong>I have yet to find a way to auto-size shapes based on the picture fill so you should make sure to adjust all signature files to have the appropriate ratio as I have talked about in the <a href="http://www.erickscottjohnson.com/blog--examples/how-to-watermark-word-documents-with-powershell">How to Watermark Word Dcouments with PowerShell</a> guide. &nbsp;Adding white space around the signature image to get the correct ratio if you have multiple names with varying lengths would also work.<br /><br /><strong>Solution:</strong><br />Just like the previous watermarking code, I am essentially doing the same thing here. &nbsp;Adding a shape, changing the fill, removing the lines. &nbsp;The new requirements is that I need only one signature on every document and it needs to be in a specific place on the document. &nbsp;I needed to find a way to specifically place the signature on the signature line.<br /><br />I realized that you can add a title to a shape and then search for the shape via PowerShell so that is what I decided to do. &nbsp;Instead of having my script create the shape, I needed it to already be there and aligned on the signature line. &nbsp;I added the fill manually to check the signature location and also made sure to adjust the shape to be above the signature line.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/1942068_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Once the alignment was complete. I removed the picture fill and ran the code. &nbsp;Here is the final result:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/3164402_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><strong>How to Use:</strong><br /><span>Save the script as "WordSignature.ps1" and run in either one of two ways:</span><ol><li>PowerShell:<ol><li>./Word<span>Signature</span> &lt;full file location&gt;&nbsp;&lt;full watermark location&gt;</li></ol></li><li>Command Prompt:<ol><li>powershell -command "&lt;full script location&gt;&nbsp;&lt;full file location&gt;&nbsp;&lt;full watermark location&gt;"</li></ol></li></ol><strong>Tips:</strong><br />Be sure that all signatures are in a format that removes the background such as .png or .gif. &nbsp;I have made mine via a simple WordArt .png made in PowerPoint. &nbsp;You can similarly use the Shapes -&gt; Scribble option in PowerPoint to allow people to manually draw their signatures via a tablet or mouse before exporting them as .png files.<br /><br /><strong>Notes for Release:</strong><br /><strong>1.1:</strong> The size of the initial shape you choose is what defines the max allowable size of the inserted signatures. ($SigMaxH,&nbsp;$SigMaxW)<br /><strong>1.0:</strong> <strong>(Fixed in version 1.1.)&nbsp;</strong><span>If you are going to use multiple names as signature, make sure to adjust the ratios of all pictures to be the same to avoid shrinking or stretching issues.</span></div>  <div id="743752029360772780"><div><style type="text/css">	#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--light {  padding: 20px 0px;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--light .header .paragraph {  margin: 0;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--dark {  padding: 20px 0px;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--dark .header .paragraph {  margin: 0;}#element-6e6230de-c44c-4619-919f-f03a7118b28c .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-6e6230de-c44c-4619-919f-f03a7118b28c" data-platform-element-id="270170748587580171-1.3.1" class="platform-element-contents">	<div class="code-editor--dark">    <div class="header">        <div class="paragraph" style="text-align:left;">WordSignature.ps1</div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>]]></content:encoded></item><item><title><![CDATA[How to Watermark Word Documents with PowerShell]]></title><link><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-watermark-word-documents-with-powershell]]></link><comments><![CDATA[https://www.erickscottjohnson.com/blog--examples/how-to-watermark-word-documents-with-powershell#comments]]></comments><pubDate>Sun, 05 Jun 2016 06:27:55 GMT</pubDate><category><![CDATA[PowerShell]]></category><category><![CDATA[Watermark]]></category><category><![CDATA[Word]]></category><guid isPermaLink="false">https://www.erickscottjohnson.com/blog--examples/how-to-watermark-word-documents-with-powershell</guid><description><![CDATA[           A simple script that automates the watermarking of documents in Word.      Summary:The below script will automate the process of watermarking documents in Word.Problem Overview:I needed a way to automatically create watermarks on Word documents without any user interaction as part of a larger script.Limitations Encountered:Although Word has a built in ribbon button for watermarking, I have not been able to find a way to call it in PowerShell. &nbsp;When adding a picture in a document, [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.erickscottjohnson.com/uploads/7/6/2/5/76257945/9438353_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div class="paragraph" style="text-align:left;"><span>A simple script that automates the watermarking of documents in Word.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:left;"><strong>Summary:</strong><br /><span>The below script will automate the process of watermarking documents in Word.</span><br /><br /><strong>Problem Overview:</strong><br /><span>I needed a way to automatically create watermarks on Word documents without any user interaction as part of a larger script.</span><br /><br /><strong>Limitations Encountered:</strong><br /><span>Although Word has a built in ribbon button for watermarking, I have not been able to find a way to call it in PowerShell. &nbsp;When adding a picture in a document, you are not given the ability to alter the transparency like a true watermark.</span><br /><br /><strong>Solution:</strong><br /><span>In order to add a picture and control its transparency, you have to first create a shape and then fill that shape with an image. &nbsp;Because you can control the transparency of the shape's fill, you can now control the transparency of the watermark image. &nbsp;To make it look like a shape is not even there, the default outlines of the shape should also be hidden/removed.</span><br /><br /><strong>How to Use:</strong><br /><span>Save the script as "WordWatermarking.ps1" and run in either one of two ways:</span><ol><li>PowerShell:<ol><li>./WordWatermarking &lt;full file location&gt;&nbsp;&lt;full watermark location&gt;</li></ol></li><li>Command Prompt:<ol><li>powershell -command "&lt;full script location&gt;&nbsp;&lt;full file location&gt;&nbsp;&lt;full watermark location&gt;"</li></ol></li></ol><strong>Tips:</strong><br />A watermark looks better when the image has no background. &nbsp;If the image used has a background, then you will get the block look which seems unprofessional. &nbsp;Because we are not all image experts, the easiest way to create a watermark image that does not have a background is to use WordArt and shapes in PowerPoint. &nbsp;Simply create the design, select all objects, right click, Save as Picture. &nbsp;This creates a .png file with the background removed that you can use for your watermarks.<br /><br />The shape does not automatically change size based on the size of the picture. &nbsp;You should adjust the shape size manually below (the 500, 125 numbers) to be the same ratio as the image you are going to use. i.e. if I have a watermark that is 1.6" x .9" (or even 160 pixels by 90 pixels), I would size the shape to be 160 x 90 or 320 x 180 or 80 x 45. &nbsp;This prevents the image from looking like it is being stretched or shrunk.</div>  <div id="917504303538916809"><div><style type="text/css">	#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--light {  padding: 20px 0px;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--light .header .paragraph {  margin: 0;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--dark {  padding: 20px 0px;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--dark .header .paragraph {  margin: 0;}#element-35e70f40-a156-4d0d-9e85-2c619437fa36 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-35e70f40-a156-4d0d-9e85-2c619437fa36" data-platform-element-id="270170748587580171-1.3.1" class="platform-element-contents">	<div class="code-editor--dark">    <div class="header">        <div class="paragraph" style="text-align:left;">WordWatermarking.ps1</div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>]]></content:encoded></item></channel></rss>