Remotely monitor a scrpt

I have written a few scripts which take days to complete (it migrates VMs in vSphere from datastore to datastore) and I want to be able to monitor it from my phone. Is this possible?

I don’t have a specific example for you as I haven’t done this, but working it from the end of your question back I think the first problem is the phone.
Does your phone have secure remote connectivity back to your work LAN? What OS is your phone running? What kind of capabilities is it going to have for getting information about a remote computer? I.e. can it query snmp, check Event Viewer, read a file over SMB? Whatever your options are will kind of help define what you do.

On the script side of things the world is your oyster I suppose. Log progress to a text file. Convert the whole thing to run as background jobs and then monitor the status of those background jobs. Send events to Event Viewer and monitor those logs for status.

I suspect this is one of those moments I often have where I’m so focused on thinking of how to do something in Powershell I don’t stop to think if I should do something in Powershell.
image

I’d suggest taking a look at what vSphere is already tracking in regards to your tasks/events, and what its reporting capabilities are. Maybe you can just get it to send you an email when a certain kind of task is started and completed.

Or just the script sends you periodic email updates? That seems a lot easier

Good thoughts here from @grey0ut and @neemobeer

I’d add to this that this question is super open ended, and it doesn’t inherently seem to be a PowerShell question, though I presume the scripts in question are written in PowerShell. The answer to most questions ‘is something possible’ is almost always ‘yes’ but it depends on how much work you are willing to put into it to make it happen, and whether or not your company will give you the time/resources to build that solution.

Are you only looking to monitor your script? What all does the script do? Are you just needing the status of the script? Are you really more concerned about if the process completed? vSphere almost certainly has logs itself for migrations, but unsure if those are helpful to you. Key Metrics for Monitoring VMware VSphere | Datadog (datadoghq.com) suggests a log file. I don’t work as a vsphere administrator so I can’t verify what is or isn’t possible with those though.

You can build in logging into your scripts to write to a data source, and make that data queryable. You can even ingest that data into something like Microsoft Sentinel or LogAnalytics to make more accessible from your phone. You could build other non Powershell solutions i’m sure that would fit the need.

Hi guys, thanks for your responses. I guess using email notifications is one idea which would be simple to implement.
I was hoping to have a setup where say My Synology NAS runs code which accepts text from a specific port which is forwarded from my router and somehow the phone could have like a terminal window which would read those messages so I could watch the status as it runs.
I guess this type of setup would need some programming as it may not already exist.
Thanks.

Although my vote is for e-mail as that seems pretty simple, what about having the NAS send you a text? The backend to your NAS is Linux where you can do just about anything.