Need help joining to domain during provision

21 views
Skip to first unread message

Edward Evans

unread,
Sep 15, 2016, 2:30:21 PM9/15/16
to Vagrant
I am also having trouble adding the machine to the domain during provision.  I am using a SHELL provisioner and running a BoxStarter script which has something like

$computer = Get-WMIObject win32_computersystem
$memberStatus = ($computer).domainrole
$domainName = "myDomain.com"

if ($memberStatus -eq 0 -or $memberStatus -eq 2)  
{
    $User = "myDomain.com\SuperUser"
    $pWord = ConvertTo-SecureString –String "Passw0rd!" –AsPlainText -Force
    $cred = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $User, $PWord
        #Add the computer to the domain if it's a 'Standalone Workstation' (0) or 'Standalone Server' (2) only
        Add-Computer -DomainName $domainName -NewName $computer -Credential $cred
        #Add 'Domain Users' to the Local Administrators group on the computer
        $group = [ADSI]"WinNT://./Administrators,group"
        $group.Add("WinNT://$domainName/My.User,$group")

        if (Test-PendingReboot){Invoke-Reboot}
    
}


But I get 

==> Client:  Chocolatey installed 1/1 package(s). 0 package(s) failed.                                         
==> Client:   See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).                         
==> Client:  + Boxstarter finished Calling Chocolatey to install dotnet3.5. This may take several minutes to co
mplete... 00:03:12.1516303                                                                                     
==> Client:  ConvertTo-SecureString : The parameter value "Æ'?String Passw0rd! Æ'?AsPlainText" is not a valid 
encrypted string.                                                                                              
==> Client:  At C:\ProgramData\chocolatey\lib\temp_BoxstarterPackage\tools\ChocolateyInstall.ps1:15 char:14    
==> Client:  + ...    $pWord = ConvertTo-SecureString Æ'?"String "Passw0rd!" Æ'?"AsPlainT ...                 
==> Client:  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                       
==> Client:                                                                                                    
==> Client:      + CategoryInfo          : InvalidArgument: (:) [ConvertTo-SecureString], PSArgumentException  
==> Client:      + FullyQualifiedErrorId : ImportSecureString_InvalidArgument,Microsoft.PowerShell.Commands.Con
vertToSecureStringCo                                                                                           
==> Client:     mmand                                                                                          
==> Client:  New-Object : Cannot find type [Æ'?TypeName System.Management.Automation.PSCredential Æ'?ArgumentLi
st]: verify that the as                                                                                        
==> Client:  sembly containing this type is loaded.                                                            
==> Client:                                                                                                    
==> Client:  At C:\ProgramData\chocolatey\lib\temp_BoxstarterPackage\tools\ChocolateyInstall.ps1:16 char:13    
==> Client:  +     $cred = New-Object Æ'?"TypeName "System.Management.Automation.PSCr ...                      
==> Client:  +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                           
==> Client:      + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException                  
==> Client:      + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand         


Any help appreciated.

Ed

Alvaro Miranda Aguilera

unread,
Sep 15, 2016, 5:53:29 PM9/15/16
to vagra...@googlegroups.com
hello

seems the script is failing on
$pWord = ConvertTo-SecureString –String "Passw0rd!" –AsPlainText -Force

seems is taking the asplaintext as part of the password

check the encoding of the script, ie open it on plain notepad
check the dash - are correct, sometimes windows editors change -- to some nicelooking char that is not - -

Alvaro

On Thu, Sep 15, 2016 at 8:30 PM, Edward Evans <ed.e...@gmail.com> wrote:
==> Client:  ConvertTo-SecureString : The parameter value "Æ'?String Passw0rd! Æ'?AsPlainText" is not a valid 
encrypted string.    




--

Edward Evans

unread,
Sep 16, 2016, 12:52:48 PM9/16/16
to Vagrant
I was using SublimeText3 which was writing it as utf8.  I changed it to use Western (Windows 1252) and it got passed that issue and then complained about computername...I've added $computer.name and am trying that.
Thanks so much!

Edward Evans

unread,
Sep 16, 2016, 6:19:00 PM9/16/16
to Vagrant
That fixed it...thanks so much!
Reply all
Reply to author
Forward
0 new messages