locked
Importing DHCP scopes via Powershell RRS feed

  • Question

  • I am deploying a Windows 2012 R2 via MDT 2013.  One of my last steps(at this time) is to import the DHCP scopes.  I have a Task sequence steps that adds the role, stops the services, adds the migration tools, adds the migration tools snapin.  I have a step that will import the scopes.  However, the scopes reside on a network share.  How do I pass the credentials in my script?  I have something that MAY work, just not sure.  Any pointers will be appreciated.  Here is the script that I have.  I will test tomorrow, but would like guidance tonight before I test

    +++++++++++++++++

    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 

    #Path to scope file (ScopePAth recieved from Task Sequence Variable)
    $strScopePath=$tsenv.Value("ScopePath")

    # Encrypted password for scope file
    $Pass = convertto-securestring -string "PASSWORD" -asplaintext -force

    # Domain Credentials
    $strUser = "domain\user"
    $strCredPass=ConvertTo-SecureString "PASSWORD" -AsPlainText -Force
    $Credentials=New-Object System.Management.Automation.PSCredential $strUser, $strCredPass

    # Adds the Migration Tools Snapin
    Add-PSSnapin microsoft.windows.servermanager.migration

    Import-SmigServerSetting -featureID DHCP -Force -path $strScopePath -Password $Pass -Credentials $Credentials

    ++++++++++++++++

    Thanks very much

    Wednesday, February 24, 2016 12:19 AM