generate_signatures_module.psm1
function createOutlookSingaturesOpenmatic($ucode) { $ADemploye=Get-ADUser -Identity $Ucode -Properties mobilePhone,Description,Department,Company,Title,Manager,division,BusinessCategory #$ADemploye.BusinessCategory $jmeno=$ADemploye.GivenName $primeni=$Ademploye.Surname #$pozice=$ADemploye.Description $temp1="FSsign:\TEMP\openmatics_temp" #$temp2="FSsign:\TEMP\Signatures_temp2" $pathcopy = "FSsign:\openmatics" $path = "C:\temp\Signatures_" + $ADemploye.SamAccountName if (Test-Path $path) { Remove-Item -Path $path -Force -Recurse } mkdir $path $temp=$temp1 $txt=Get-Content ($temp+"\openmatics_temp.txt") $txt = $txt.replace("Jmeno",$jmeno) $txt = $txt.replace("prijmeni",$primeni) $txt | Out-File ($path + "\openmatics.txt") -Force $txt=Get-Content ($temp+"\openmatics_temp.htm") $txt = $txt.replace("Jmeno",$jmeno) $txt = $txt.replace("prijmeni",$primeni) $txt = $txt.replace("openmatics_temp_files",("openmatics_files")) $txt | Out-File ($path + "\openmatics.htm") -Force $txt=Get-Content ($temp+"\openmatics_temp.rtf") -Encoding utf8 $txt = $txt.replace("Jmeno",$jmeno) $txt = $txt.replace("prijmeni",$primeni) #$txt | Out-File ($path + "\CI.rtf") -Encoding utf8 -Force Add-Content -Value $txt -Path ($path + "\openmatics.rtf") -Force #Add-Content -Value $txt -Path ("FSsign:\users\Signatures_hraj\CI_"+$pozice+".rtf") -Force #$txt | Out-File ($path + "\CI_"+$pozice+".rtf") -Force Copy-Item -Path ($temp+"\openmatics_temp_files") -Destination ($path+"\openmatics_files") -Force -Recurse if (Test-Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName)) { Remove-Item -Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) -Force -Recurse } mkdir ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) Copy-Item -Path $path -Destination $Pathcopy -Force -Recurse Remove-Item -Path $path -Force -Recurse } function createOutlookSingaturesGlobal($ucode) { $ADemploye=Get-ADUser -Identity $Ucode -Properties mobilePhone,Description,Department,Company,Title,Manager,division,BusinessCategory #$ADemploye.BusinessCategory $jmeno=$ADemploye.GivenName $primeni=$Ademploye.Surname $mobil=$Ademploye.MobilePhone $replacemail=(RemoveDiacritics $jmeno)+"."+(RemoveDiacritics $primeni) $replacemail=$replacemail.ToLower() $ADemploye.BusinessCategory[0].Split(";") #$pozice=$ADemploye.Description $temp1="FSsign:\Global_temp\Signatures_temp" $temp2="FSsign:\Global_temp\Signatures_temp2" $pathcopy = "FSsign:\users" if ($Ademploye.Department -eq "SUP"){ $temp1="FSsign:\Global_temp\Support_temp" $temp2="FSsign:\Global_temp\Support_temp" $pathcopy = "FSsign:\users" createOutlookSingaturesOpenmatic $ADemploye.SamAccountName } $path = "C:\temp\Signatures_" + $ADemploye.SamAccountName if (Test-Path $path){ Remove-Item -Path $path -Force -Recurse } mkdir $path for ($i=0;$i -lt ($ADemploye.BusinessCategory.count) ;$i++) { $bu=0 $ii=$i+1 $pozicex= $ADemploye.BusinessCategory[$i].Split(";") if ($pozicex[2].length -gt 3) { $ii=$pozicex[0] $pozice=$pozicex[1] $bu=1 $buname=$pozicex[2] $temp=$temp2 } else { $ii=$pozicex[0] $pozice=$pozicex[1] $temp=$temp1 } $txt=Get-Content ($temp+"\CI_temp.txt") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt | Out-File ($path + "\CI_"+$ii+"_BeDigitalFaster.txt") -Force $txt=Get-Content ($temp+"\CI_temp.htm") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt = $txt.replace("CI_temp_files",("CI_"+$ii+"_BeDigitalFaster_files")) $txt | Out-File ($path + "\CI_"+$ii+"_BeDigitalFaster.htm") -Force Copy-Item -Path ($temp+"\CI_temp_files") -Destination ($path+"\CI_"+$ii+"_BeDigitalFaster_files") -Force -Recurse } Remove-Item -Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) -Force -Recurse mkdir ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) Copy-Item -Path $path -Destination $Pathcopy -Force -Recurse Remove-Item -Path $path -Force -Recurse $pathhtml = "FSsign:\users\Signatures_"+ $ADemploye.SamAccountName+"\CI_1_BeDigitalFaster.htm" $sigHTML="$(Get-Content -Path $pathhtml -ReadCount 0)" $sigHTML = $sigHTML.replace("CI_1_BeDigitalFaster_files/","http://var.aimtec.cz/pictures/") Set-MailboxMessageConfiguration -Identity $Ucode -SignatureHtml $sigHTML } function createOutlookSingatures($ucode) { createOutlookSingaturesGlobal $ucode createOutlookSingaturesAction_mkt_prot $ucode } function createOutlookSingaturesAction($ucode) { $ADemploye=Get-ADUser -Identity $Ucode -Properties mobilePhone,Description,Department,Company,Title,Manager,division,BusinessCategory #$ADemploye.BusinessCategory $jmeno=$ADemploye.GivenName $primeni=$Ademploye.Surname $mobil=$Ademploye.MobilePhone $replacemail=(RemoveDiacritics $jmeno)+"."+(RemoveDiacritics $primeni) $replacemail=$replacemail.ToLower() $ADemploye.BusinessCategory[0].Split(";") #$pozice=$ADemploye.Description $temp1="FSsign:\TEMP\Signatures_temp" $temp2="FSsign:\TEMP\Signatures_temp2" $pathcopy = "FSsign:\users" if ($Ademploye.Department -eq "SUP"){ $temp1="FSsign:\TEMP\Support_temp" $temp2="FSsign:\TEMP\Support_temp" $pathcopy = "FSsign:\users" createOutlookSingaturesOpenmatic $ADemploye.SamAccountName } $path = "C:\temp\Signatures_" + $ADemploye.SamAccountName if (Test-Path $path){ Remove-Item -Path $path -Force -Recurse } mkdir $path for ($i=0;$i -lt ($ADemploye.BusinessCategory.count) ;$i++) { $bu=0 $ii=$i+1 $pozicex= $ADemploye.BusinessCategory[$i].Split(";") if ($pozicex[2].length -gt 3) { $ii=$pozicex[0] $pozice=$pozicex[1] $bu=1 $buname=$pozicex[2] $temp=$temp2 } else { $ii=$pozicex[0] $pozice=$pozicex[1] $temp=$temp1 } $txt=Get-Content ($temp+"\CI_temp.txt") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt | Out-File ($path + "\CI_"+$ii+".txt") -Force $txt=Get-Content ($temp+"\CI_temp.htm") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt = $txt.replace("CI_temp_files",("CI_"+$ii+"_files")) $txt | Out-File ($path + "\CI_"+$ii+".htm") -Force Copy-Item -Path ($temp+"\CI_temp_files") -Destination ($path+"\CI_"+$ii+"_files") -Force -Recurse } #Remove-Item -Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) -Force -Recurse #mkdir ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) Copy-Item -Path $path -Destination $Pathcopy -Force -Recurse Remove-Item -Path $path -Force -Recurse } function createOutlookSingaturesAction_mkt_tmp($ucode) { $ADemploye=Get-ADUser -Identity $Ucode -Properties mobilePhone,Description,Department,Company,Title,Manager,division,BusinessCategory #$ADemploye.BusinessCategory $jmeno=$ADemploye.GivenName $primeni=$Ademploye.Surname $mobil=$Ademploye.MobilePhone $replacemail=(RemoveDiacritics $jmeno)+"."+(RemoveDiacritics $primeni) $replacemail=$replacemail.ToLower() $ADemploye.BusinessCategory[0].Split(";") #$pozice=$ADemploye.Description $temp1="FSsign:\TEMP_MKT_tmp\Signatures_temp" $temp2="FSsign:\TEMP_MKT_tmp\Signatures_temp2" $pathcopy = "FSsign:\users" if ($Ademploye.Department -eq "SUP"){ $temp1="FSsign:\TEMP_MKT_tmp\Support_temp" $temp2="FSsign:\TEMP_MKT_tmp\Support_temp" $pathcopy = "FSsign:\users" #createOutlookSingaturesOpenmatic $ADemploye.SamAccountName } $path = "C:\temp\Signatures_" + $ADemploye.SamAccountName if (Test-Path $path){ Remove-Item -Path $path -Force -Recurse } mkdir $path for ($i=0;$i -lt ($ADemploye.BusinessCategory.count) ;$i++) { $bu=0 $ii=$i+1 $pozicex= $ADemploye.BusinessCategory[$i].Split(";") if ($pozicex[2].length -gt 3) { $ii=$pozicex[0] $pozice=$pozicex[1] $bu=1 $buname=$pozicex[2] $temp=$temp2 } else { $ii=$pozicex[0] $pozice=$pozicex[1] $temp=$temp1 } $txt=Get-Content ($temp+"\CI_temp.txt") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt | Out-File ($path + "\CI_"+$ii+".txt") -Force $txt=Get-Content ($temp+"\CI_temp.htm") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt = $txt.replace("CI_temp_files",("CI_"+$ii+"_files")) $txt | Out-File ($path + "\CI_"+$ii+".htm") -Force Copy-Item -Path ($temp+"\CI_temp_files") -Destination ($path+"\CI_"+$ii+"_files") -Force -Recurse } #Remove-Item -Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) -Force -Recurse #mkdir ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) Copy-Item -Path $path -Destination $Pathcopy -Force -Recurse Remove-Item -Path $path -Force -Recurse #$pathhtml = "FSsign:\users\Signatures_"+ $ADemploye.SamAccountName+"\CI_1.htm" #$sigHTML="$(Get-Content -Path $pathhtml -ReadCount 0)" #$sigHTML = $sigHTML.replace("CI_1_files/","http://var.aimtec.cz/pictures/") #Set-MailboxMessageConfiguration -Identity $Ucode -SignatureHtml $sigHTML } function createOutlookSingaturesAction_mkt_prot($ucode) { $ADemploye=Get-ADUser -Identity $Ucode -Properties mobilePhone,Description,Department,Company,Title,Manager,division,BusinessCategory #$ADemploye.BusinessCategory $jmeno=$ADemploye.GivenName $primeni=$Ademploye.Surname $mobil=$Ademploye.MobilePhone $replacemail=(RemoveDiacritics $jmeno)+"."+(RemoveDiacritics $primeni) $replacemail=$replacemail.ToLower() $ADemploye.BusinessCategory[0].Split(";") #$pozice=$ADemploye.Description $temp1="FSsign:\tmp_live\Signatures_temp" $temp2="FSsign:\tmp_live\Signatures_temp2" $pathcopy = "FSsign:\users" if ($Ademploye.Department -eq "SUP"){ $temp1="FSsign:\tmp_live\Support_temp" $temp2="FSsign:\tmp_live\Support_temp" $pathcopy = "FSsign:\users" #createOutlookSingaturesOpenmatic $ADemploye.SamAccountName } $path = "C:\temp\Signatures_" + $ADemploye.SamAccountName if (Test-Path $path){ Remove-Item -Path $path -Force -Recurse } mkdir $path for ($i=0;$i -lt ($ADemploye.BusinessCategory.count) ;$i++) { $bu=0 $ii=$i+1 $pozicex= $ADemploye.BusinessCategory[$i].Split(";") if ($pozicex[2].length -gt 3) { $ii=$pozicex[0] $pozice=$pozicex[1] $bu=1 $buname=$pozicex[2] $temp=$temp2 } else { $ii=$pozicex[0] $pozice=$pozicex[1] $temp=$temp1 } $txt=Get-Content ($temp+"\CI_temp.txt") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt | Out-File ($path + "\CI_"+$ii+".txt") -Force $txt=Get-Content ($temp+"\CI_temp.htm") $txt = $txt.replace("mobil",$mobil) $txt = $txt.replace("xxx",$jmeno) $txt = $txt.replace("yyy",$primeni) $txt = $txt.replace("replacemail",$replacemail) $txt = $txt.replace("pozice",$pozice) if ($bu -eq 1) { $txt = $txt.replace("businessUnit",$buname) } $txt = $txt.replace("CI_temp_files",("CI_"+$ii+"_files")) $txt | Out-File ($path + "\CI_"+$ii+".htm") -Force Copy-Item -Path ($temp+"\CI_temp_files") -Destination ($path+"\CI_"+$ii+"_files") -Force -Recurse } #Remove-Item -Path ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) -Force -Recurse #mkdir ($PathCopy+"\Signatures_"+$ADemploye.SamAccountName) Copy-Item -Path $path -Destination $Pathcopy -Force -Recurse Remove-Item -Path $path -Force -Recurse #$pathhtml = "FSsign:\users\Signatures_"+ $ADemploye.SamAccountName+"\CI_1.htm" #$sigHTML="$(Get-Content -Path $pathhtml -ReadCount 0)" #$sigHTML = $sigHTML.replace("CI_1_files/","http://var.aimtec.cz/pictures/") #Set-MailboxMessageConfiguration -Identity $Ucode -SignatureHtml $sigHTML } function RemoveDiacritics { param ($s) $s = $s.Normalize([System.Text.NormalizationForm]::FormD); $sb = ""; for ($i = 0; $i -lt $s.Length; $i++) { if ([System.Globalization.CharUnicodeInfo]::GetUnicodeCategory($s[$i]) -ne [System.Globalization.UnicodeCategory]::NonSpacingMark ) { $sb += $s[$i] ; } } return $sb; } Export-ModuleMember -Function 'RemoveDiacritics' Export-ModuleMember -Function 'createOutlookSingaturesAction_mkt_tmp' Export-ModuleMember -Function 'createOutlookSingaturesAction_mkt_prot' Export-ModuleMember -Function 'createOutlookSingaturesAction' Export-ModuleMember -Function 'createOutlookSingatures' Export-ModuleMember -Function 'createOutlookSingaturesGlobal' Export-ModuleMember -Function 'createOutlookSingaturesOpenmatic' |