Scheduled-Backup-Scripts (PowerShell): impossible to shutdown a Disk Station via PLink...


Scheduled-Backup-Scripts (PowerShell): impossible to shutdown a Disk...
Author
Message
Joachim
Joachim
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)
Group: Forum Members
Posts: 27, Visits: 34

Hi together,

again, I have problems to shutdown my DS after Backup from the scheduled Backup-Task.
In the past I called my compiled WScript.exe-File from Reflects VBScript-Backup-Script to start-up or shutdown my DS. Under Reflect v6 it works fine; under v7 not, equal if the script is running under the User Accounts "Admin" or "SYSTEM".

Because the trouble, I changed some details to reduce PLink-parameters and then tested with PowerShell.
First I created with PuTTYgen Key-files created, sudoers permissions seted,... and a working ssh-session in PuTTY defined; so, if I start the PuTTY-session "ShdSessionDS" with User "ShdUser", so I can perform the command "sudo /sbin/shutdown -P +3 DS-Shutdown after Backup.".

After this I have created a Reflect-Scheduled-Backup-Job for testing (standard under Windows 7) and let generating a PowerShell-Script (see: attachment).
Then I added to this script the, outside of Reflect working, lines in "function DSShutdown()". But no success! Neither under the accounts of "Admin" nor "SYSTEM".
Then I copied this script into the PowerShell-ISE and comment out the Backup-line: "$iExitCode = Backup;" for testing (without a Backup) – no success, too. But the "function DSShutdown()" alone is working!
So I comment out the line "Elevate;" and the shutdown of my DS was performed!

At this point, I have actually no ideas to solve this problem.
But it would be very helpful, because I do inside my originally script a lot of things more; like starting the DS and shutdown the DS in some circumstances only, writing a own log file and so on.

One possible important remark: If I start the script (from attachment) manually from "Scheduled Backups" I see under "Last Results" for a few seconds then message: "0x41325 Error" (User Accout = Admin).

Thanks for any help!

Best regards, Joachim.


Environment: Reflect v7.1.3317, Windows 7, x64, Ultimate.


Attachments
PLink-Test.ps1.txt (0 views, 12.00 KB)
Joachim
Joachim
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)
Group: Forum Members
Posts: 27, Visits: 34

Main problem solved! Sorry, for this almost unnecessary topic.

Problem cause "DS does not shut down" / "PLink does not run correctly":
The PuTTY session I use in the PLink command had a bug in the admin account; so the PLink command couldn't work.
Under my 'User' account the PuTTY session was error free and the shutdown of the DS worked.

After correcting the 'Admin' PuTTY session, the PLink command works fine from the 'elevated' script in conjunction of 'Task Scheduler user credentials' = Admin.

In retrospect, the mistake was logical and the solution simple.
As the saying goes: "Often the problem is between two ears". ;-)


However, the error described remains: 0x41325 under "Last Result" for a few seconds when manually executing a Scheduled Task!
Is there any knowledge in this context? And what does this error mean?
Should I open an extra topic?


jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)Macrium Evangelist (6.5K reputation)
Group: Forum Members
Posts: 4.4K, Visits: 32K
Does that task scheduler code occur when you run a scheduled task that calls a completely standard Reflect backup script, before any of your modifications? The error code is based on the outcome of the entire scheduled task, so if you introduce other work into the script, then those new elements can affect the result of the scheduled task even if the Reflect portion completed just fine. I don’t know Putty or PLink well enough to help chase that down or even know whether there might be a way to avoid it. That said, if Reflect and PLink both work and you don’t have any additional functionality set to occur based on the reported outcome of the scheduled task, then it may not be worth spending too much time chasing down. You shouldn’t be looking at the outcome of the scheduled task to determine whether a Reflect job was successful anyway; that’s what the log view is for.
Nick
Nick
Macrium Representative
Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)Macrium Representative (3K reputation)
Group: Administrators
Posts: 1.8K, Visits: 9.6K
Joachim - 1 September 2018 2:46 PM

Main problem solved! Sorry, for this almost unnecessary topic.

Problem cause "DS does not shut down" / "PLink does not run correctly":
The PuTTY session I use in the PLink command had a bug in the admin account; so the PLink command couldn't work.
Under my 'User' account the PuTTY session was error free and the shutdown of the DS worked.

After correcting the 'Admin' PuTTY session, the PLink command works fine from the 'elevated' script in conjunction of 'Task Scheduler user credentials' = Admin.

In retrospect, the mistake was logical and the solution simple.
As the saying goes: "Often the problem is between two ears". ;-)


However, the error described remains: 0x41325 under "Last Result" for a few seconds when manually executing a Scheduled Task!
Is there any knowledge in this context? And what does this error mean?
Should I open an extra topic?


Hi

Sorry for the confusion.

'0x41325' means 'The Task Scheduler service has asked the task to run'. It isn't an error. 

https://docs.microsoft.com/en-us/windows/desktop/taskschd/task-scheduler-error-and-success-constants

Kind Regards

Nick - Macrium Support

Joachim
Joachim
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)
Group: Forum Members
Posts: 27, Visits: 34
Hi Nick, thanks for Information.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search