web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to know Powershell script is running?

(0) ShareShare
ReportReport
Posted on by 709

Hi guys,

I'm not sure I can get any answers or I'm in the right forum, but anyhow this is the only forum I 'live' with. So I have a question regarding my task to run a Powershell script which is the script is to run an RSAT (well, at least the RSAT is still F&O related). What I've been explore is, this script executed by put in Task scheduler. 

The setting is to run the Powershell.exe with the argument is the script file it self. Something like this:

pastedimage1611977170104v2.png

I can share the content of the script if needed, but what I want to ask is how to know whether my script is run or not ? at the moment, when task is executed it will pop up Powershell window but blank only, I don't know whether it is running or error or simply not execute my script.

The intention of this script is to run my RSAT Testplan which already configured in my RSAT installation.

Thanks,

I have the same question (0)
  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: How to know Powershell script is running?

    I'm sorry, but I can't comment on Powershell code I've never seen. Please use a Powershell debugger to see what's going on in your code.

    You could share the script file by uploading it somewhere and adding a link here. Note that a Powershell forum may be more approprioate for questions about Powershell.

  • ShaqAX Profile Picture
    709 on at
    RE: How to know Powershell script is running?

    Hi,

    Thanks for the mentioning the error. It is quite difficult without me posting the script it self.

    But, yes, it has this statement:

       $LogFile = $LogDirTmp + $name + ".txt"

       Write-Output "1. $(Get-TimeStamp) Test case #: $TestCaseStr" | Out-file $LogFile -append

    For the process, what I understand is like this:

    1. The script supposed to be "Run" one time but it will act as a service, so it will observe one folder

    2. When file arrived, the script is run, it has mechanism of moving the said file to another location with also produce log file

    3. The main action on this script is to run RSAT with TestCase specified inside the file.

    Here is the Youtube channel if you would like to take a look.

    www.youtube.com/watch

    btw, if you do watch the Youtube, it is also talking about Flow, which I already did and the Flow (and the file) is created. But anyway it is out of the scope of my question.

    Thanks

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: How to know Powershell script is running?

    Okay, I mentioned your problem in Community Feedback Forum. Please keep the code; maybe admins will need it to reproduce the problem.

    Back to your problem. I'm still not sure what you mean about the log. Are you saying that there is some logging, but it doesn't cover errors, therefore it's not relevant to what we're discussing here?

    Also, could you explain what you're doing? You said you want to execute the script when there is a file, but it sounds strange to me. In theory, you could run something when a file gets created, but you seem to be using Task Scheduler, therefore I thought you want to do it on schedule. Isn't it the case. Also, executing a script and keeping a script running are two completely different things. You mentioned both, therefore it's not clear what you're doing.

    Can't you keep it simple - let the script processes all files in the folder and ends, and run this periodically on schedule? I thought this is what you're doing, but some of your remarks suggest that you're attempting something else.

  • ShaqAX Profile Picture
    709 on at
    RE: How to know Powershell script is running?

    Hi,

    Yes, the output of the script besides run RSAT TestPlan, also create a log file, so if the script works, I will see a new file which is the log.

    "Put the script" is actually I tried to copy paste that script into this discussion but it always failed.

    I always get this error :

    pastedimage1612165069347v1.png

    Using Insert code tools in this forum, it is even worse, I get this message:

    pastedimage1612165164975v2.png

    The main question is still how to know the script is still running, because this script is supposed to detect whenever there is a file, it will executed.

    Thanks

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: How to know Powershell script is running?

    I'm sorry, but I'm not sure what you're saying.

    Does "in this script however will create some log file" means that you have logging in place and it does work"?

    What are you talking about when you say "I tried to put the script many times" and what was the error? Where exactly does it happen? We can't help you with the error if you don't tell us anything about it.

    Does it mean that your question isn't "How to know Powershell script is running?" anymore, and you need help with an error instead?

  • ShaqAX Profile Picture
    709 on at
    RE: How to know Powershell script is running?

    Hi Martin,

    I honestly never write PowerShell Script before, but this time for some purposes I need to use this and I get it from someone. And as I checked, it has "Write-Output" , because in this script however will create some log file whenever the RSAT completed.

    I'm sorry I tried to put the script many times but produce error .

    My changes to the script is just the folder path and it is define as variables. A few point is that:

    1. The idea of this script is, it will observe the folder Z:\RSAT_IN, whenever there are files in it, it will run the command to start RSAT and move the file to Z:\RSAT_ARCHIVE

    2. The RSAT it self is confirmed to run well

    Thanks,

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: How to know Powershell script is running?

    You didn't mention any redirection to file. Do you have something like that there? If not, Write-Host (if the script doesn't fail even before reaching this command) simply adds a message to the console, which you won't see anywhere.

  • ShaqAX Profile Picture
    709 on at
    RE: How to know Powershell script is running?

    Hmm, I actually add Write-Host in some of the line. Does it meant it's actually never run and never read my script?

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: How to know Powershell script is running?

    I would start with redirecting the script output to a file. You can also add extra messages to help you tracking the progress.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,351

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 874 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 638 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans