Error -:
New-Object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)). At D:\get-process.ps1:5 char:12 + $Outlook = New-Object -ComObject Outlook.Application + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (:) [New-Object], COMExcept ion + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Comman ds.NewObjectCommand You cannot call a method on a null-valued expression. At D:\get-process.ps1:6 char:1 + $Mail = $Outlook.CreateItem(0) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull The property 'To' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:8 char:1 + $Mail.To = "$username" + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound The property 'Subject' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:9 char:1 + $Mail.Subject = "New Leave Request" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound The property 'Body' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:10 char:1 + $Mail.Body = "$username" + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound You cannot call a method on a null-valued expression. At D:\get-process.ps1:12 char:1 + $Mail.Send() + ~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Hello devang_gaur@outlook.com
get-process.php -:
<?php
$username = "devang_gaur@outlook.com";
$psScriptPath = "D:\\get-process.ps1";
$query = shell_exec("powershell -command $psScriptPath -username '$username'< NUL");
echo $query;
?>
get-process.ps1 -:
param(
[string]$username
)
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "$username"
$Mail.Subject = "New Leave Request"
$Mail.Body = "$username"
$Mail.Send()
Write-Output "Hello $username <br />"
get-process.php
is the php that is present in root folder wwwroot
of IIS Windows Server 2012 and from which the PowerShell script get-process.ps1
is triggered. Get-process.ps1
contains script for sending the mail