MDT 2013 Task Sequence Variables - DHCP Scope Importing RRS feed

  • Question

  • I have a task sequence that deploys Windows 2012 and installs the DHCP scope.  I have a group of steps that will install DHCP, install the server tools.  These are done via powershell.  Everything works fine.  I have a powershell script that will map a network drive to a share that contains the DHCP scopes to import.  I have that script below.  Nothing too difficult.  Now, use the script as it is here, I get an error (I have included a pic of the error).  


    # Sets Task Sequence Environment
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 

    #Sets Task Sequence variables

    #Converts Password to secure Text
    $Pass = convertto-securestring -string $DHCPPass -asplaintext -force
    $strCredPass=ConvertTo-SecureString $strPassword -AsPlainText -Force

    #Sets domain credentials for mapped drive
    $ShareCred=New-Object System.Management.Automation.PSCredential $strLogin, $strCredPass

    # Maps drive to share with the DHCP scope import shares 
    New-PSDrive -Name Z -PSProvider FileSystem -Root \\address\DHCPSites -Credential $ShareCred -Persist

    #Adds Migration Snapin

    #Imports Scope
    Import-SmigServerSetting -featureID DHCP -Force -path $strScopePath -Password $Pass


    If I remove the """ around the password variables (coming from my CS.ini file), I get a different error that states my password is null when it attempts to convert it to secure text.   Now, if I remove the variables from the CS.ini file altogether (ie $strlogin="domain\username", $strpass="password", $strpath="c:\test"  the script works flawlessly.  What would be the syntax to get these variables from CS.ini and use them in my script?  Thanks

    Wednesday, February 24, 2016 7:56 PM