0 votes

For a custom command, I need to perform some actions, then reboot a computer, then perform some more. How can we handle the reboot so the actions continue once the computer is back up and ready?

Thanks

by (100 points)

1 Answer

0 votes
by (11.0k points)

Hello!

Do we understand correctly that the custom command is configured for the Computer object type and the computer on which the command is executed must be rebooted? If so, you can consider the possibility of using the following approach. In the custom command, add the actions that must be executed before the computer reboot. As the last action in the custom command, add the Update the computer action that will mark the computer by setting a custom Date attribute to the current date/time. Create a scheduled task that will check if the last reboot time of the computer is greater than the value of the custom Date attribute. The check must be performed using the If PowerShell script returns True condition. If the condition is met, the task will execute the actions required after the computer reboot. For information on how to get the date/time when the computer was last rebooted, have a look at the following Microsoft article: https://devblogs.microsoft.com/scripting/powertip-get-the-last-boot-time-with-powershell/.

If this is not what you meant, please, provide us with all the possible details regarding the required behavior with screenshots and live examples.

0

That's correct, and I thought of something like that, but the caveat is the timing of the scheduled task. I'd like to execute the post-reboot actions as soon as possible once the computer is back up, but I don't really want to be having a scheduled task run every minute.

0

Hello,

Thank you for specifying. Unfortunately, there is no other possibility to perform actions after a computer reboot except using a scheduled task. Adaxes service is not aware of a computer reboot, thus there must be some task that will check if the computer was actually rebooted.

0

I understand. Is there a way to enable/disable scheduled task from within a custom command? Then I could enable it when CustomCommand1 is waiting for reboot. And disable it again once actions are complete

0

Hello,

Yes, it is possible to enable/disable a scheduled task using the below PowerShell script. In the script:

  • $tsakDN - Specifies the distinguished name (DN) of the scheduled task that will be enabled or disabled. For information on how to get the DN, have a look at the following SDK article: http://adaxes.com/sdk/HowDoI.GetDnOfObject.
  • $taskDisabled - Specifies if the task must be disabled. Set the variable value to True to disable the task, and False - to enable the task.
$taskDN = "CN=MyScheduledTask,CN=Scheduled Tasks,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$taskDisabled = $False # TODO: modify me

# Bind to the scheduled task
$task = $Context.BindToObjectByDN($taskDN)

# Enable/disable the scheduled task
$task.Disabled = $taskDisabled
$task.SetInfo()
0

thank you

Related questions

0 votes
0 answers

Hello! We have a business rule in place that will request approval from a group's owner before adding an account to that group for certain groups. We also have a custom ... name reference is invalid. Do you have any ideas for how to get around this error?

asked Jan 24, 2022 by KelseaIT (320 points)
0 votes
1 answer

I have a Web Interface for our Voice and Data group. With this interface they manage and create VPN users. They've asked for a report that they need to import into ... the regular employee users which are part of the report are for view and export only?

asked Jul 26, 2018 by rurbaniak (1.4k points)
0 votes
1 answer

Hello, I am working on delegating the ability to create user accounts. One thing I'm not sure how to handle is duplicate user names. I would like it if I could have an ... gets passed off to me to create manually so I'd love to be able to automate it!

asked Mar 24, 2016 by drew.tittle (810 points)
0 votes
1 answer

I need to know how to Create a new Custom Attribute which I wants save some informations of Users

asked Jun 12, 2023 by kanishka.silva (40 points)
0 votes
1 answer

Hi, is there a possibility to show some custom read only text in Custom Command? Ideally on page where users fill in parameter values of given Custom Command.

asked Jan 22, 2020 by KIT (910 points)
3,326 questions
3,026 answers
7,727 comments
544,678 users