Link to home
Start Free TrialLog in
Avatar of barry buchanan
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.
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Post what you're trying to do, it will be easier for us to track what are the changes required, please.

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
Avatar of barry buchanan
barry buchanan

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_Reception_2019-03-18.html", but it is empty, i am not sure if there is other code issues as the file is empty and no errors.

############ 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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 :) )