Forum Discussion
How to add social media podcast to existing PowerShell Script to display in HTML for email signature
Hi Christina_B5749,
its really hard to read this. You can format code as code:
Anyways..
About the errors. Regardless about the outcome, the errors are all errors, that are explaining theirself.
Christina_B5749 wrote:This is the error:
+ mkdir $FolderLocation
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (C:\Users\bolden...oft\signatures\:String) [New-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
In this case the Directory already Exists.
You can check if a dir exists like this:
Test-Path C:\users\admin\Please provide further details, maybe marked as code 😉
Best regards,
Schnittlauch
"First, No system is safe. Second, Aim for the impossible. Third, no Backup, no Mercy" - Schnittlauch
My answer helped you? Don't forget to leave a like. Also mark the answer as solved when your problem is solved. 🙂
- Christina_B5749Jul 19, 2022Copper Contributor
Schnittlauch Thank you!
I've attached the full PowerShell script into a word document. Hopefully this is easily legible in this format. I've also highlighted the line that I am currently working on and trying to include in an email signature the Apple Podcast logo with a clickable link to it.
I do have the below path on my computer.
############################################################# #Modified by Ghost in the Machine 10-13-15 #This Powershell Script creates Outlook signatures for Active Direcory users and sets it as their default at logon $strName = $env:username $strFilter = "(&(objectCategory=User)(samAccountName=$strName))" $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.Filter = $strFilter $objPath = $objSearcher.FindOne() $objUser = $objPath.GetDirectoryEntry() $strName = $objUser.DisplayName if ($objUser.Properties.Contains("extensionAttribute2") -and -not [string]::IsNullOrWhiteSpace($objUser.extensionAttribute2[0])) { $strNameWithPronouns = "$($objUser.DisplayName) $($objUser.extensionAttribute2[0])"; } else { $strNameWithPronouns = $objUser.DisplayName; } $strTitle = $objUser.Title $strCompany = $objUser.Company $strDepartment = $objUser.Department $strPhone = $objUser.telephoneNumber $strFax = $objUser.faxnumber $strcellPhone = $objUser.mobile $strEmail = $objUser.emailaddress $strwwwHomePage = "$($user.wWWHomePage)" #above strwwwhomepage used for Assitant line $UserDataPath = $Env:appdata #Signature Folder Location $FolderLocation = $UserDataPath + '\\Microsoft\\signatures\\' #Checks for existing signature #$path = $FolderLocation + $strname + '.htm' # If ((Test-Path -path $path) -eq $true) { break } # Else { mkdir $FolderLocation #Sets Outlook to force signature Remove-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Outlook\Setup\ -name First-Run New-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings -Name "NewSignature" -Value "$strname" -PropertyType "String" New-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings -Name "ReplySignature" -Value "$strname" -PropertyType "String" #Creates HTML Signature $stream = [System.IO.StreamWriter] "$FolderLocation\\$strName.htm" $stream.WriteLine("<!DOCTYPE HTML PUBLIC `"-//W3C//DTD HTML 4.0 Transitional//EN`">") $stream.WriteLine("<HTML><HEAD><TITLE>Signature</TITLE>") $stream.WriteLine("<META http-equiv=Content-Type content=`"text/html; charset=windows-1252`">") $stream.WriteLine("<BODY>") #Name of Employee $stream.WriteLine("<Table border =`'0`'><tr><td><B><SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`">" + $strNameWithPronouns + "</B></SPAN></td></tr>") #Title & Company Name $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>" + $strTitle + $strCompany + " | " + $strDepartment + "</td></tr>") #NEA $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>National Endowment for the Arts</td></tr>") #Street Address, Room, City $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>400 7th Street SW | Washington DC 20506</SPAN></td></tr>") #Email & Telephone Numbers $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>" + $strEmail + " | 202-682-" + $strPhone + " (p) | " + $strFax + "</SPAN></td></tr>") #Second Line for Assistant for Laura Callanan $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>" + $strwwwhomepage + "</SPAN></td></tr>") #Social Media $stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>Learn more about the arts in your community at <a href='http://www.arts.gov'>arts.gov</a>") #$stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>Celebrating the NEA's 50th Anniversary at <a href='https://www.arts.gov/50th'>arts.gov/50th</a>.</SPAN></td></tr>") #$stream.WriteLine("<SPAN style=`"FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: `'Calibri`'`"><tr><td nowrap=`'nowrap`'>To join the discussion on how art works, visit the NEA at <a href='http://www.arts.gov'>arts.gov</a>, <a href='http://www.facebook.com/nationalendowmentforthearts'>Facebook</a>, <a href='http://www.twitter.com/neaarts'>Twitter</a>, <a href='https://podcasts.apple.com/us/podcast/art-works-podcast/id1058911829'>Art Works Podcast</a>.</SPAN></td></tr>") $stream.WriteLine("</BODY>") $stream.WriteLine("</HTML>") $stream.WriteLine("</DIV>") $stream.close() #Creates TXT Signature $stream = [System.IO.StreamWriter] "$FolderLocation\\$strName.txt" $stream.WriteLine("$strName") #Title & Company Name $stream.WriteLine("$strTitle $strCompany | $strDepartment ") #NEA $stream.WriteLine("National Endowment for the Arts") #Street Address, Room, City $stream.WriteLine("400 7th Street SW | Washington DC 20506") #Email & Telephone Numbers $stream.WriteLine("$strEmail | 202-682-$strPhone (p) | $strFax") #Social Media #$stream.WriteLine("To join the discussion on how art works, visit the NEA at www.arts.gov, Facebook, Twitter, Apple Art Works Podcast.") #$stream.WriteLine("In celebration of the NEA's 50th, we're gathering stories about the impact of art on people's lives. Click here to share your story!") $stream.WriteLine("Learn more about the arts in your community at https://www.arts.gov") $stream.WriteLine("https://www.arts.gov/sites/default/files/2018-%20Horizontal-Logo-white-on-black-with-url.png") $stream.close()