This topic contains 2 replies, has 2 voices, and was last updated by
March 16, 2014 at 6:21 am #13826ParticipantPoints: 0Rank: Member
I am trying to get an HTML file attached and e-mailed to myself.
I run a weekly script that gets and e-mails the Replication status and FSMO Roles of the Domain Controllers on the network.
The Replication Status HTML file gets attached and sent without any issues, it's the FSMO Roles HTML file that does not get attached.
I get the following error message:
Send-MailMessage : Cannot find drive. A drive with the name 'The syntax of this command is
At D:\Software\ReplicationScripts\HTMLScript.ps1:72 char:17
+ Send-MailMessage <<<< -to $toaddress -Bcc $bccaddress -From $fromaddress -Attachments " host -Subject $subject -BodyAsHtml $msgbody + CategoryInfo : ObjectNotFound: (The syntax of this command is:String) [Send Exception + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SendMailMessage I have attached the script that I am trying to run. Could you please point me in the right direction. Regards.
March 16, 2014 at 6:27 am #13828MemberPoints: 0Rank: Member
Looks like you've redefined your $FSMORoles variable several times in the code. At first, it contains a file path suitable to be passed to the -Attachments parameter of Send-MailMessage, but later on, it'll contain something else.
$FSMORoles = "E:\Software\ReplicationScripts\FSMORoles.html" #... $FSMORoles=netdom query FSMORoles > E:\Software\ReplicationScripts\FSMORoles.txt #... $FSMORoles = Get-Content $FSMORoles #... Send-MailMessage -Attachments "$FullReplication","$FSMORoles" #...
March 16, 2014 at 8:07 am #13836ParticipantPoints: 0Rank: Member
Thanks a mill,
The issue has been resolved,
The variable should have been:
$FSMORoles=netdom query FSMO > E:\Software\ReplicationScripts\FSMORoles.txt
As you pointed out, the $FSMORoles variable had a few more inconsistencies which I have also corrected.
The topic ‘Attach and send HTML file’ is closed to new replies.