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
+ 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.
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.