Thanks for your reply.
Let me tell you what exactly I want to perform.
I will execute .bat file in which I will mention xml,ps1,log file paths.
Program is divided into 3 parts: pre-processing ,main(),post processing
I want to login to multiple tenant mail boxes delete there previous mail, send mail and receive mail reception. In getcred() I am encrpting password using converttosecurestring commandlet.
I want to execute this using powershell 7 and EWS API.
Please tell me should I need to change script function sequence or what.
Out of all this functionality which code should be there inside parallel block.
Please find below error msg:
C:\Projects\Code Files_Parallel_Processing for multiple tenants>set PS1='C:\Projects\Code Files_Parallel_Processing for multiple tenants\File.ps1'
C:\Projects\Code Files_Parallel_Processing for multiple tenants>set LOG='C:\Projects\Code Files_Parallel_Processing for multiple tenants\POC-DeleteChange.log'
C:\Projects\Code Files_Parallel_Processing for multiple tenants>set XML='C:\Projects\Code Files_Parallel_Processing for multiple tenants\POC.xml'
C:\Projects\Code Files_Parallel_Processing for multiple tenants>cd /d C:\Projects\Code Files_Parallel_Processing for multiple tenants\
C:\Projects\Code Files_Parallel_Processing for multiple tenants>Powershell.exe -command "&{&'C:\Projects\Code Files_Parallel_Processing for multiple tenants\testforsp.ps1' 'C:\Projects\Code Files_Parallel_Processing for multiple tenants\POC-DeleteChange.log' 'C:\Projects\Code Files_Parallel_Processing for multiple tenants\POC.xml';exit $LASTEXITCODE}"
INFO001 [Started email sending / receiving normality monitoring tool.] Log file:C:\Projects\Code Files_Parallel_Processing for multiple tenants\POC-DeleteChange.log, Configuration file:C:\
Projects\Code Files_Parallel_Processing for multiple tenants\POC.xml
INFO002 Pre-process.
INFO 003 Load the configuration file.
Tenant Details - pv1@Stuff .com C:\Projects\Code Files_Parallel_Processing for multiple tenants\EncryptedPassWord.txt
Tenant Details - pv2@Stuff .com C:\Projects\Code Files_Parallel_Processing for multiple tenants\EncryptedPassWord2.txt
INFO004 Starts the main process.
ErrorLog =>Parameter set cannot be resolved using the specified named parameters.
ERROR032 The main process could not continue because an error occurred in the main process.
ERROR032 The main process could not continue because an error occurred in the main process.
PS C:\Projects\Code Files_Parallel_Processing for multiple tenants>
Script execution flow is as follows:
- Adding xml,ps1,log file path in .bat file
- running .bat file in terminal
- File.ps1 structure:
reading xml,log file
variable declaration
initial processing function
init()
{
checkxml()
getxml()
}
main()
{
try{
$collection = foreach ($tenantDetails in $script:gXMLINFO.tenants.tenant) {
$out = [ordered]@{
tid = $tenantDetails.id
tmailbox = $tenantDetails.box
tpass = $tenantDetails.password
}
[pscustomobject]$out
}
$collection | ForEach-Object -Parallel {
getcred() #require to login to mailbox
deletemail()
sendmail()
receive()
Actual lines where getting cred,delete,send mail works
foreach ($tenantDetails in $script:gXMLINFO.tenants.tenant) {
if ( (GetCredential) -eq $false) {
return $false
}
if ( (SendMailMessage $script:gLOGINID) -eq $false) {
return $false
}
}
}##parallel block close
}##main close
trigger point of script
initialize()
main()
post processing
printing error logs
Please Please help me out.
Thanks in advance.