generate_signatures_cloud.psm1
function get-GlobalTemp($globaltemppath) { Remove-Item $globaltemppath -Recurse -Force mkdir $globaltemppath $dirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "Global_temp" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($dir in $dirs) { $sudirname=$dir.Name mkdir $globaltemppath\$sudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "Global_temp\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $globaltemppath\$sudirname $sudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "Global_temp\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($sudir in $sudirs) { $susudirname=$sudir.name $susudirname mkdir $globaltemppath\$sudirname\$susudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "Global_temp\$sudirname\$susudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $globaltemppath\$sudirname\$susudirname } } } function get-ActionTemp($Actiontemppath) { Remove-Item $Actiontemppath -Recurse -Force mkdir $Actiontemppath $dirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($dir in $dirs) { $sudirname=$dir.Name mkdir $Actiontemppath\$sudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $Actiontemppath\$sudirname $sudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($sudir in $sudirs) { $susudirname=$sudir.name $susudirname mkdir $Actiontemppath\$sudirname\$susudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname\$susudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $Actiontemppath\$sudirname\$susudirname } } } 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; } function removeSignatures($ruser) { $ruser $rdirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir in $rdirs) { $rdir $suname=$rdir.name $rsudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser/$suname" | Get-AzStorageFile |Remove-AzStorageFile Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser/$suname" } Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} |Remove-AzStorageFile do{ Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser" -ErrorAction Continue Start-Sleep -Seconds 2 "remove" Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser" -verbose }while (Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$ruser") } function uploadsignatures($uuser) { "upload" new-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser" -verbose "upload1" $1folders=Get-ChildItem $path -Directory "upload2" $0files=Get-ChildItem -Path $path -file foreach ($0file in $0files) { $0filename=$0file.name $0filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser/$0filename" -Source $0file.fullname -verbose } "upload3" ForEach ($1folder in $1folders) { $1foldername=$1folder.Name $1foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser/$1foldername" -verbose $1files=Get-ChildItem -Path $1folder.FullName -file foreach ($1file in $1files) { $1filename=$1file.name $1filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser/$1foldername/$1filename" -Source $1file.fullname -verbose } $2folders=Get-ChildItem -Path $1folder.FullName -Directory ForEach ($2folder in $2folders) { $2foldername=$2folder.Name $2foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser/$1foldername/$2foldername" -verbose $2files=Get-ChildItem -Path $2folder.FullName -file foreach ($2file in $2files) { $2filename $2filename=$2file.name Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "users/Signatures_$uuser/$1foldername/$2foldername/$2filename" -Source $2file.fullname -verbose } } } "upload end" } function generateGlobalSignautures($pozice,$buname,$ii) { #$pozice=$ADemploye.Description $temp1="$globaltemp\Signatures_temp" $temp2="$globaltemp\Signatures_temp2" $pathcopy = "C:\temp\users" $temp1 $temp2 $path = "C:\temp\Signatures_" + $EmployeeCode $bu = 0 mkdir $path if ($buname.length -gt 5) { $bu = 1 $temp=$temp2 "temp2" }else{ $temp=$temp1 "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 -verbose } function generateActionSignautures($pozice,$buname,$ii) { #$pozice=$ADemploye.Description $temp1="$ActionTemp\Signatures_temp" $temp2="$ActionTemp\Signatures_temp2" $pathcopy = "C:\temp\users" $temp1 $temp2 $path = "C:\temp\Signatures_" + $EmployeeCode #if (Test-Path $path){ #Remove-Item -Path $path -Force -Recurse #} if (!(test-path $path)) { mkdir $path } $bu = 0 if ($buname.length -gt 5) { $bu = 1 $temp=$temp2 "temp2" }else{ $temp=$temp1 "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 -verbose } function get-TEMP_MKT_banner($bannertemppath) { Remove-Item $bannertemppath -Recurse -Force mkdir $bannertemppath Get-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_banner/image007.png" -destination "$bannertemppath/image007.png" Get-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_banner/link.txt" -destination "$bannertemppath/link.txt" } function get-TEMP_MKT($tempsignaturespath) { Remove-Item $tempsignaturespath -Recurse -Force mkdir $tempsignaturespath $dirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($dir in $dirs) { $sudirname=$dir.Name mkdir $tempsignaturespath\$sudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $tempsignaturespath\$sudirname $sudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($sudir in $sudirs) { $susudirname=$sudir.name $susudirname mkdir $tempsignaturespath\$sudirname\$susudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT\$sudirname\$susudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $tempsignaturespath\$sudirname\$susudirname } } } function removeTMPSignatures() { $rdirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir in $rdirs) { $rdir $suname=$rdir.name $rsudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$suname" | Get-AzStorageFile |Remove-AzStorageFile $rdirs2=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$suname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir2 in $rdirs2) { $rdir2 $suname2=$rdir2.name Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$suname/$suname2" | Get-AzStorageFile |Remove-AzStorageFile } Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$suname/$suname2" Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$suname" } } function uploadTMPSignatures($uploadpath) { "upload" new-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp" -verbose "upload1" $1folders=Get-ChildItem $uploadpath -Directory "upload2" $0files=Get-ChildItem -Path $uploadpath -file foreach ($0file in $0files) { $0filename=$0file.name $0filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$0filename" -Source $0file.fullname -verbose } "upload3" ForEach ($1folder in $1folders) { $1foldername=$1folder.Name $1foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$1foldername" -verbose $1files=Get-ChildItem -Path $1folder.FullName -file foreach ($1file in $1files) { $1filename=$1file.name $1filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$1foldername/$1filename" -Source $1file.fullname -verbose } $2folders=Get-ChildItem -Path $1folder.FullName -Directory ForEach ($2folder in $2folders) { $2foldername=$2folder.Name $2foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$1foldername/$2foldername" -verbose $2files=Get-ChildItem -Path $2folder.FullName -file foreach ($2file in $2files) { $2filename $2filename=$2file.name Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp/$1foldername/$2foldername/$2filename" -Source $2file.fullname -verbose } } } "upload end" } function generateActionSignauturesTMP($pozice,$buname) { #$pozice=$ADemploye.Description $temp1="$ActionTempTMP\Signatures_temp" $temp2="$ActionTempTMP\Signatures_temp2" $pathcopy = "C:\temp\users" $temp1 $temp2 $path = "C:\temp\Signatures_" + $EmployeeCode #if (Test-Path $path){ #Remove-Item -Path $path -Force -Recurse #} mkdir $path $bu = 0 if ($buname.length -gt 5) { $bu =1 $temp=$temp2 "temp2" }else{ $temp=$temp1 "temp1" } $ii="TMP" $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 -verbose } function get-TEMP_MKT_tmp($tempsignaturespath) { Remove-Item $tempsignaturespath -Recurse -Force mkdir $tempsignaturespath $dirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($dir in $dirs) { $sudirname=$dir.Name mkdir $tempsignaturespath\$sudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $tempsignaturespath\$sudirname $sudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($sudir in $sudirs) { $susudirname=$sudir.name $susudirname mkdir $tempsignaturespath\$sudirname\$susudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "TEMP_MKT_tmp\$sudirname\$susudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $tempsignaturespath\$sudirname\$susudirname } } } function archiveSignatures() { $archive="c:\temp\archive" Remove-Item $archive -Recurse -Force mkdir $archive $dirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory" -and $_.Name -ne "archive"} foreach ($dir in $dirs) { $sudirname=$dir.Name mkdir $archive\$sudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $archive\$sudirname $sudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($sudir in $sudirs) { $susudirname=$sudir.name $susudirname mkdir $archive\$sudirname\$susudirname Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\$sudirname\$susudirname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent -destination $archive\$sudirname\$susudirname } } $x=get-date $actTimestamp=$x.tostring("yyyy-MM-dd-HH-mm") "upload" new-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp" -verbose "upload1" $1folders=Get-ChildItem $archive -Directory "upload2" $0files=Get-ChildItem -Path $archive -file foreach ($0file in $0files) { $0filename=$0file.name $0filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp/$0filename" -Source $0file.fullname -verbose } "upload3" ForEach ($1folder in $1folders) { $1foldername=$1folder.Name $1foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp/$1foldername" -verbose $1files=Get-ChildItem -Path $1folder.FullName -file foreach ($1file in $1files) { $1filename=$1file.name $1filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp/$1foldername/$1filename" -Source $1file.fullname -verbose } $2folders=Get-ChildItem -Path $1folder.FullName -Directory ForEach ($2folder in $2folders) { $2foldername=$2folder.Name $2foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp/$1foldername/$2foldername" -verbose $2files=Get-ChildItem -Path $2folder.FullName -file foreach ($2file in $2files) { $2filename $2filename=$2file.name Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live\archive\$actTimestamp/$1foldername/$2foldername/$2filename" -Source $2file.fullname -verbose } } } "upload end" $rdirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory" -and $_.Name -ne "archive"} foreach ($rdir in $rdirs) { $rdir $suname=$rdir.name $rsudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$suname" | Get-AzStorageFile |Remove-AzStorageFile $rdirs2=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$suname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir2 in $rdirs2) { $rdir2 $suname2=$rdir2.name Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$suname/$suname2" | Get-AzStorageFile |Remove-AzStorageFile } Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$suname/$suname2" Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$suname" } } function uploadProdSignatures($uploadpath) { "upload" new-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live" -verbose "upload1" $1folders=Get-ChildItem $uploadpath -Directory "upload2" $0files=Get-ChildItem -Path $uploadpath -file foreach ($0file in $0files) { $0filename=$0file.name $0filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$0filename" -Source $0file.fullname -verbose } "upload3" ForEach ($1folder in $1folders) { $1foldername=$1folder.Name $1foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$1foldername" -verbose $1files=Get-ChildItem -Path $1folder.FullName -file foreach ($1file in $1files) { $1filename=$1file.name $1filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$1foldername/$1filename" -Source $1file.fullname -verbose } $2folders=Get-ChildItem -Path $1folder.FullName -Directory ForEach ($2folder in $2folders) { $2foldername=$2folder.Name $2foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$1foldername/$2foldername" -verbose $2files=Get-ChildItem -Path $2folder.FullName -file foreach ($2file in $2files) { $2filename $2filename=$2file.name Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "tmp_live/$1foldername/$2foldername/$2filename" -Source $2file.fullname -verbose } } } "upload end" } function generatebase64signatures($htm_path) { # $path = "C:\temp\Signatures_" + $EmployeeCode # Specify the path to the HTML file $htmlFilePath = $htm_path.FullName # # $htmlFilePath = "C:\Users\jirih\Downloads\CI_1.htm" # Get the file path from $htmlFilePath $filePath = Split-Path -Path $htmlFilePath -Parent Set-Location -Path $filePath # Read the HTML file content $htmlContents = Get-Content -Path $htmlFilePath $imageTags = $htmlContents | Where-Object { $_ -like "*CI_*_files*.png*"} # Loop through each image tag foreach ($imageTag in $imageTags) { # Extract the source attribute value from the image tag $src = $imageTag -replace ".*src=`"([^`"]+)`".*", '$1' # Read the image file as bytes $imageBytes = [System.IO.File]::ReadAllBytes( (join-path -Path $filePath -ChildPath $src)) # Convert the image bytes to base64 $base64Image = [System.Convert]::ToBase64String($imageBytes) # Replace the image source with the base64 encoded version $htmlContents = $htmlContents -replace [regex]::Escape($src), "data:image/png;base64,$base64Image" } # Save the modified HTML content back to the file $pathwww $pathbase64=$pathwww + "\"+ $htm_path.BaseName + "_base64.htm" $pathbase64Files=$pathwww + "\"+$htm_path.BaseName+"_files" if (!(Test-Path $pathbase64Files)) { mkdir $pathbase64Files } $htmlContents | Set-Content -Path $pathbase64 -Encoding unicode Copy-Item -Path $filePath\CI_1_files -Destination $pathbase64Files -Recurse -Force -Exclude *.png } function uploadwebsignatures($uuser) { "upload" new-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser" -verbose "upload1" $1folders=Get-ChildItem $pathwww -Directory "upload2" $0files=Get-ChildItem -Path $pathwww -file foreach ($0file in $0files) { $0filename=$0file.name $0filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser/$0filename" -Source $0file.fullname -verbose } "upload3" ForEach ($1folder in $1folders) { $1foldername=$1folder.Name $1foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser/$1foldername" -verbose $1files=Get-ChildItem -Path $1folder.FullName -file foreach ($1file in $1files) { $1filename=$1file.name $1filename Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser/$1foldername/$1filename" -Source $1file.fullname -verbose } $2folders=Get-ChildItem -Path $1folder.FullName -Directory ForEach ($2folder in $2folders) { $2foldername=$2folder.Name $2foldername New-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser/$1foldername/$2foldername" -verbose $2files=Get-ChildItem -Path $2folder.FullName -file foreach ($2file in $2files) { $2filename $2filename=$2file.name Set-AzStorageFileContent -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$uuser/$1foldername/$2foldername/$2filename" -Source $2file.fullname -verbose } } } "upload end" } function removeSignaturesweb($ruser) { $ruser $rdirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir in $rdirs) { $rdir $suname=$rdir.name $rdirs2=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser/$suname" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFileDirectory"} foreach ($rdir2 in $rdirs2) { $rdir2 $suname2=$rdir2.name $rsudirs2=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser/$suname/$suname2" | Get-AzStorageFile |Remove-AzStorageFile Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser/$suname/$suname2" } $rsudirs=Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser/$suname" | Get-AzStorageFile |Remove-AzStorageFile Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser/$suname" } Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser" | Get-AzStorageFile | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} |Remove-AzStorageFile do{ Remove-AzStorageDirectory -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser" -ErrorAction Continue Start-Sleep -Seconds 2 "remove" Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser" -verbose }while (Get-AzStorageFile -Context $Context -ShareName 'outlooksignatures' -Path "web/users/$ruser") } |