Jump to content

Kelechi93

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by Kelechi93

  1. so my path would be: \\PREP-AD02\AD Resources$\Signature.docx - ExecutionPolicy Bypass -File "Signature.ps1" (something like this????)
  2. Much Obliged, it's not too big an issue placing that anywhere on my script is there?????
  3. HELP!!!!!!!!! I'm trying to upload a powershell script i made via Group Policy Management to generate email signatures for Staff via Active Directory, but every time i upload the script on and login, all i get is a black screen and when i remove it, it goes back to normal. I've checked Event Viewer and can't seem to find the source, any one have any ideas???????? Here's the script below if anyone whose curious: #Custom variables $SignatureName = 'Signature' $SigSource = "\\PREP-AD02\AD Resources$\Signature.docx" #Path to the *.docx file$SignatureVersion = "1.7" #Change this if you have updated the signature. If you do not change it, the script will quit after checking for the version already on the machine $ForceSignature = '1' #Set to 1 if you don't want the users to be able to change signature in Outlook #Environment variables $AppData=(Get-Item env:appdata).value $SigPath = '\Microsoft\Signatures' #Path to signatures. $LocalSignaturePath = $AppData+$SigPath $RemoteSignaturePathFull = $SigSource #Check signature path (needs to be created if a signature has never been created for the profile if (-not(Test-Path -path $LocalSignaturePath)) { New-Item $LocalSignaturePath -Type Directory} #Copy version file If (-not(Test-Path -Path $LocalSignaturePath\$SignatureVersion)) { If (Test-Path HKCU:'\Software\Microsoft\Office\16.0') { $ForceKeyPathReply = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').ReplySignature -eq $null $ForceKeyPathNew = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').NewSignature -eq $null If ($ForceKeyPathReply -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' -name ReplySignature} Else {Write-Host "The reg value does not exist"} If ($ForceKeyPathNew -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' -name NewSignature} Else {Write-Host "The reg value does not exist"} } If ($ForceSignature -eq '1') { Get-ChildItem -Path $LocalSignaturePath -Recurse | foreach {remove-item $_.fullname -recurse -force -ErrorAction SilentlyContinue} } New-Item -Path $LocalSignaturePath\$SignatureVersion -ItemType Directory } Elseif (Test-Path -Path $LocalSignaturePath\$SignatureVersion) { break } #Get Active Directory information for current user $UserName = $env:username $Filter = "(&(objectCategory=User)(samAccountName=$UserName))" $Searcher = New-Object System.DirectoryServices.DirectorySearcher $Searcher.Filter = $Filter $ADUserPath = $Searcher.FindOne() $ADUser = $ADUserPath.GetDirectoryEntry() $ADDisplayName = $ADUser.DisplayName $ADEmailAddress = $ADUser.mail $ADTitle = $ADUser.title $ADTelePhoneNumber = $ADUser.TelephoneNumber $ADModify = $ADUser.whenChanged #Copy signature templates from source to local Signature-folder Write-Output "Copying Signatures" Copy-Item "$Sigsource" $LocalSignaturePath -Recurse -Force $ReplaceAll = 2 $FindContinue = 1 $MatchCase = $False $MatchWholeWord = $True $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue $Format = $False #Insert variables from Active Directory to rtf signature-file $MSWord = New-Object -ComObject word.application $fullPath = $LocalSignaturePath+'\'+$SignatureName+'.docx' $MSWord.Documents.Open($fullPath) #User Name $FindText = "DisplayName"$ReplaceText = $ADDisplayName.ToString()$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #Title $FindText = "Title" $ReplaceText = $ADTitle.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #Email Address $FindText = "e-mail" $ReplaceText = $ADEmailAddress.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #Save new message signature Write-Output "Saving signatures"#Save HTML $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML"); $path = $LocalSignaturePath+'\'+$SignatureName+".htm" $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat) #Save RTF $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF"); $path = $LocalSignaturePath+'\'+$SignatureName+".rtf" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat) #Save TXT $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText"); $path = $LocalSignaturePath+'\'+$SignatureName+".txt" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat) $MSWord.ActiveDocument.Close() $MSWord.Quit() #Office 2016 signature If (Test-Path HKCU:Software\Microsoft\Office\16.0) { If ($ForceSignature -eq '0') { $ForceKeyPathReply = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').ReplySignature -eq $null $ForceKeyPathNew = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').NewSignature -eq $null If ($ForceKeyPathReply -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings' -name ReplySignature} Else {Write-Host "The reg value does not exist"} If ($ForceKeyPathNew -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings' -name NewSignature} Else {Write-Host "The reg value does not exist"} $MSWord = New-Object -comobject word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$SignatureName $EmailSignature.ReplyMessageSignature=$SignatureName $MSWord.Quit() } If ($ForceSignature -eq '1') { $MSWord = New-Object -comobject word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$SignatureName $EmailSignature.ReplyMessageSignature=$SignatureName $MSWord.Quit() If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings') { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force } If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings') { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force } } }
  4. My school uses Foldr which is linked to our network drive to share ipad photos/files of the sort
  5. damn that's expensive
×
×
  • Create New...