Cannot run Dcpromo /unattend command in primal forms 2011

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 9 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
CSC_WPS
Posts: 8
Last visit: Thu Aug 21, 2014 12:57 am

Cannot run Dcpromo /unattend command in primal forms 2011

Post by CSC_WPS »

The code for demoting the Domain Controler is not working in primal form 2011. This is my code:

If ($radiobuttonLastDCYes.Checked -eq $false)
{
dcpromo /unattend /UserName:$textboxAdministrator.Text /UserDomain:$textboxDomName.Text /Password:$textboxAdminPwd.Text /AdministratorPassword:$textboxLocAdmPwd.Text /RemoveApplicationPartitions=yes /RebootOnCompletion=yes
}

and the error that i get is:

The term dcpromo is not recognized as the name of cmdlet, function, scriptfile or operable program. Check the spelling of the name or if the path was included, verify that the path is correct and try again. Cannot bind argument to parameter 'FilePath' because it is null.

I don't understand why is it not able to recognize 'dcpromo'.
I am able to run the same command manually in powershell on WIndows Server 2008 R2. Howeever when I run this through a primal form project, I am getting the error.

I have also tried Invoke-Command, start-process, calling another ps1\cmd file to run the dcpromo commmand, but it keeps giving same error saying dcpromo not recognized.

Need urgent help as I'm out of ideas.

Thanks,
Hari
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by davidc »

If this is a cmdlet from a module or snapin, be sure to explicitly load it within your script, because PrimalForms does not load profiles. PF 2011 only supports PowerShell V2, so if the module or snapin is requires V3 or greater, it will not work at all.

David
David
SAPIEN Technologies, Inc.
User avatar
CSC_WPS
Posts: 8
Last visit: Thu Aug 21, 2014 12:57 am

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by CSC_WPS »

Its just a simple command which demotes the Domain Controller.
It runs with powershell V1 and V2 both.
Primal Forms just not able to recognize the command and says it Cannot recognize dcpromo.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by davidc »

Ok I see, Dcpromo is an external executable and not a cmdlet or alias. Most likely the problem is that dcpromo is 64 bit and PrimalForms is a 32 bit application, therefore it doesn't find the executable when running the script.

David
David
SAPIEN Technologies, Inc.
User avatar
CSC_WPS
Posts: 8
Last visit: Thu Aug 21, 2014 12:57 am

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by CSC_WPS »

Dcpromo is used to promote a server as a Domain Controller and the same command is used to demote the domain controller with different arguments.
The promotion of Domain Controller using primal Forms 2011 is working fine however the demotion is not working.

If Primal Forms cannot recognize 64 bit exe, I'm wondering how is it able to promote the server using same 'Dcpromo' command?

I'm using the exact same method to demote which is used for promotion.
User avatar
CSC_WPS
Posts: 8
Last visit: Thu Aug 21, 2014 12:57 am

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by CSC_WPS »

This is the way I'm calling dcpromo:


$demotion = "/unattend /UserName:$($textboxAdministrator.text) /UserDomain:$($textboxDomName.text) /Password:$($textboxAdminPwd.text) /AdministratorPassword:$($textboxLocAdmPwd.text) /RebootOnCompletion:yes"

###########Demoting the DC

$demoteinfo = New-Object System.Diagnostics.ProcessStartInfo("dcpromo",$demotion)
$demotestatus = [diagnostics.process]::start($demoteinfo)
$demotestatus.WaitForExit()
User avatar
CSC_WPS
Posts: 8
Last visit: Thu Aug 21, 2014 12:57 am

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by CSC_WPS »

I get the same error message even if I give the full path of 'Dcpromo'

This is the same method used to promote the Domain Controller.
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 1:15 am
Answers: 19
Been upvoted: 37 times

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by Alexander Riedel »

Replace dcpromo with Notepad.exe
See if that starts.

If it does, then you have an access or rights problem.
If that gives you the same error then your code is different for demoting than from promoting.

If you substitute notepad.exe and still get the "The term dcpromo is not recognized as ..." error, then you are looking at the wrong code.

Since we don't see your script it's hard to judge, but usually that would call for using a debugger, set a breakpoint and examine the variables at the location and follow the program logic to see if you even hit the right spot.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Cannot run Dcpromo /unattend command in primal forms 201

Post by davidc »

If the Dcpromo.exe is located the C:\Windows\System32 folder, a 32 bit app will not find it on a 64 bit OS, since the System32 folder path is mapped to a different location for 32 bit apps.

You will have to use:

C:\Windows\Sysnative

instead of:

C:\Windows\System32


FYI, PrimalForms 2011 is at end of life, and we will no longer issue service builds.

David
David
SAPIEN Technologies, Inc.
This topic is 9 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.