Page 1 of 1

Cannot run Dcpromo /unattend command in primal forms 2011

Posted: Tue Aug 19, 2014 1:55 am
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

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

Posted: Tue Aug 19, 2014 7:55 am
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

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

Posted: Wed Aug 20, 2014 1:45 am
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.

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

Posted: Wed Aug 20, 2014 8:34 am
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

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

Posted: Thu Aug 21, 2014 12:49 am
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.

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

Posted: Thu Aug 21, 2014 12:56 am
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()

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

Posted: Thu Aug 21, 2014 12:57 am
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.

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

Posted: Thu Aug 21, 2014 1:06 am
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.

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

Posted: Thu Aug 21, 2014 8:26 am
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