Add a computer to a schedule through CMD?
Is there a command to add a computer to a schedule?
Currently how I handle imaging is..
MDT images, and then using PSExec I kickoff a deployment to the local machine (incorporated in the task sequence). The deployments are for a list of baseline packages (currently 1 packages with nested packages). After watching the latest webcast the idea of having an auto-updating schedule I could remotely kick off, well that would be awesome. My idea of how to handle this would be..
Add computer to schedule, kickoff schedule, delete computer from schedule.
But I can't seem to find a way to actually add a computer to a schedule.
Comments
No, there are no commands for adding targets to a schedule. You can do it through the database, but be careful. Make sure you have a backup of your database before messing around with it.
INSERT INTO Targets (TargetType, Name) VALUES ('Computer', 'YOUR COMPUTER NAME HERE');INSERT INTO ScheduleTargets (ScheduleId, TargetId) VALUES (ID OF YOUR SCHEDULE, ID OF THE TARGET THAT WAS CREATED IN THE LINE ABOVE);
For example:
INSERT INTO Targets (TargetType, Name) VALUES ('Computer', 'SULU');INSERT INTO ScheduleTargets (ScheduleId, TargetId) VALUES (1, 3);
I'm curious, what is the ScheduleTargetId used for inside of the ScheduleTargets table?
Similarly, I can inject settings into the database and check to make sure they are there, but they don't show up in the Schedule in the Depoy Console
I had done an insert with a TargetId of 999 so I could control what the ID was programmatically and put it into the query for the ScheduleTargets insertion without having a secondary query to get it.
ScheduleTargetId is an automatically generated primary key. That's why I only defined ScheduleId and TargetId in the INSERT.
ScheduleId has to exist in the Schedules table and TargetId has to exist in the Targets table.
That makes sense. Curious why the computer name I provided isn't showing up in the schedule in PDQ Deploy. Looks like it should be right and that I should be able to see it. I'd really like to have this as well, so if I can get this working it'd be awesome!
Did you refresh the Deploy console or close and re-open it? It's possible I missed something, but I want to cover the easy stuff first :)
Yup, I absolutely tried that a couple times. I think that TargetID needs to go somewhere else as well, but I've not found it yet, and to be honest, what I've done above is really most of the effort I have put forth thus far. Have too many irons in the fire today!
This works for me:
That's so freakin weird. That code does bupkis for me. It executes without errors. I've verified that the data is in the database correctly. Nothing in the schedule. So weird. I even bounced the background service. I'll keep poking it. I'm sure it's something on my end just acting funny. Your code is solid, and as you said it works on your end. Maybe I'm just crazy haha.
So I went to lunch, came back, and looked in Deploy, and one of the schedules I was testing against has the computer I was using in it now. I even refreshed everything after running the script, but didn't see it.
Something refreshed, but I can't tell what.