Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:17:29+00:00 2026-06-15T07:17:29+00:00

When I run the PowerSheel script manually – through a .bat file that executes

  • 0

When I run the PowerSheel script manually – through a .bat file that executes it with the PowerShell interpreter – it correctly executes an SQL query and creates an Excel file and e-mails it.

If I automate it – run the .bat file that runs the PowerShell file with the interpreter through the Windows job scheduler every night – then the e-mail is sent without the file.

It is difficulty to copy the code here because I made a nice framework many functions deep with lambda-functions and all, but generally:

$ExcelWorkBook.SaveAs($Filename)

$ExcelWorkBook.Close()

$ExcelApp.Quit()

(…)

Sleep -Seconds 500

(…)

$MailMessage.Attachments.Add($Filename)

$SMTP.Send($MailMessage)

I have heard that Excel does not actually support GUI-less automation (windows task scheduler) but that actually worked for me through a different framework.

What can I do to make it work, if cannot how can I generate Excel files from PowerShell in a different way, or how can I just easily generate and e-mail reports in PowerShell?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:17:30+00:00Added an answer on June 15, 2026 at 7:17 am

    if you are running windows 2008 or above, then the job is probably executed in session0 (read about session0 isolation at microsoft).

    You have to create Desktop-Folders for session0, read more here:
    http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

    Windows 2008 Server x64
    Please make this folder
    C:\Windows\SysWOW64\config\systemprofile\Desktop

    Windows 2008 Server x86
    Please make this folder
    C:\Windows\System32\config\systemprofile\Desktop

    Then restart machine and try again.
    I got it working with GUI-less Excel automation via task scheduler and powershell, done by creating those folders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using powershell script to run a few *.sql file. I can get the
I have a complex Powershell script that gets run as part of a SQL
I have a Powershell script that calls sqlcmd to run a sql script that
I have a Powershell script that is going to be run through an automation
I'm making a .bat-file run a powershell script, and I need to make sure
I have developed a Powershell script that needs to be run automatically daily. This
I'd like to use a windows PowerShell script to run a batch file every
I'm trying to run a Powershell script to clear the Run History through the
I've written a powershell script that I run several times a day. It's getting
I run a Powershell script on a computer that has no Internet connection. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.