My commands in runonce are not running

0

0

I'm writing a script that is intended to automate the process of promoting a new domain controller where no domain previously existed.

I've been consistently caught up on how to get the program to resume after reboot, first trying workflows only to find that the install-addsforest command is bugged in workflow after a week of debugging and looking at logs, trying to use scheduled tasks only to find them worthless because the secure user id the task is registered under no longer exists after the promotion, and most recently trying to use the run once registry key along with auto-login to have my script continue after reboot.

Right now I think what is preventing the script from being run to completion is that it's not being run as Admin: it has a #requires -runasadmin flag that prevents it from being run except as an admin (and rigntfuly so) but even though I run autologin to login as an admin I can't get it to run my script from the runonce key.

Where would I go to view logs associated with this registry key, and does anyone have any recommendations?

I'm not going to DSC, by the way: I'm sick of powershell's advanced features and besides, it runs using workflows which can't successfully run a command I need.

comp.sci.intern

Posted 2017-07-17T19:00:26.883

Reputation: 13

You've hit on the underlying problem: when you promote a machine to a DC, you can no longer logon the machine using any of the local user accounts. Only domain accounts work from that point forward. There is one exception: Directory Services Restore Mode, in which the local admin account works. Not sure how much that can help you though. – I say Reinstate Monica – 2017-07-17T19:10:40.273

I've been able to get around the problem of logging onto the machine by making the autologin use $domainname\administrator but I'm just having trouble with the runonce key actually getting my script to run. – comp.sci.intern – 2017-07-18T15:28:57.720

Are you using the run once key in the HKLM or HKCU branch? – I say Reinstate Monica – 2017-07-18T16:54:43.780

I'm using the HKLM branch – comp.sci.intern – 2017-07-19T19:45:03.277

Perhaps the problem isn't due to promoting the machine to a DC? Does the script run correctly without the promotion process being involved? – I say Reinstate Monica – 2017-07-19T20:47:38.350

1I haven't tried a test run of a script without the ad promotion, but I'll try that next – comp.sci.intern – 2017-07-19T21:24:11.007

Answers

0

My problem was that the length of my runonce variable was over 255 chars. Once I pared it down I didn't have any problems getting it to run after reboot.

comp.sci.intern

Posted 2017-07-17T19:00:26.883

Reputation: 13