barry buchanan
asked on
Exchange script ouput to file generation
I had this question after viewing exchange ,script.
I am new to scripting and am trying to manipulate the same script as above to have the option of it to a local folder i.e. c:\temp directory or using the send-mail option. Any help would be good. I'm ok with hashing out each option so don't need it to automatically asking me.
I have dabbled with out-file and I can generate a file but alas it is empty, though I can't determine if this is something else I've modified in the script.
I am new to scripting and am trying to manipulate the same script as above to have the option of it to a local folder i.e. c:\temp directory or using the send-mail option. Any help would be good. I'm ok with hashing out each option so don't need it to automatically asking me.
I have dabbled with out-file and I can generate a file but alas it is empty, though I can't determine if this is something else I've modified in the script.
ASKER
im a little embarrased on what i've tried however
Two Sections involved the first is a set of variables the second is convert to html and save local, as stated I can generate a file "C:\Temp\EmailStats_Recept ion_2019-0 3-18.html" , but it is empty, i am not sure if there is other code issues as the file is empty and no errors.
Two Sections involved the first is a set of variables the second is convert to html and save local, as stated I can generate a file "C:\Temp\EmailStats_Recept
############ Start Variables
[Int] $intSent = $intRec = 0
$emails = Get-Mailbox
$StartDate = get-date -uformat "%m.01.2019"
$EndDate = get-date -uformat "%m.%d.%Y"
$tab2 = @()
$tabInfo = @()
$outfile_date = get-date -UFormat ("%Y-%m-%d")
$outfile = "C:\Temp\EmailStats_Reception_" + $outfile_date + ".html"
############ End variables
############ ConvertTo-HTML
$body = $tabInfo | ConvertTo-HTML -head $head
$body += $tab2 | ConvertTo-HTML -head $head
############ Save Local
Out-File $body -BodyAsHTML $outfile -Append
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome that worked just like magic.
Just a little correction
No need to use "body += $tab2 ...." line I've corrected on the comment
Line5 => https://www.experts-exchange.com/viewCodeSnippet.jsp?codeSnippetId=20-42822503-3
(btw I'm glad it worked :) )
No need to use "body += $tab2 ...." line I've corrected on the comment
Line5 => https://www.experts-exchange.com/viewCodeSnippet.jsp?codeSnippetId=20-42822503-3
(btw I'm glad it worked :) )
IK you referenced another script but hey! , it's a new question is better to have all the ingredients of each on each issue, more comfortable to answer too