calling .ps1 script from within TS RRS feed

  • Question

  • In our task sequence we kick off a .PS1 script at the very end.  This .PS1 script should move the computer to the correct OU based on previously gathered data.

    We have a step to "Run a Command Line"  For the command line we have this command.

    C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy bypass -file .\MoveAD.ps1

    The package step runs a package that calls this .PS1 script.

    $computer = (get-wmiobject -Class Win32_computersystem).name
    $Description = (get-ItemProperty hklm:\SOFTWARE\build).Description
    $dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $root = $dom.GetDirectoryEntry()
    $search = [System.DirectoryServices.DirectorySearcher]$root
    $search.Filter = "(cn=$computer)"
    $result = $search.FindOne()
    $computerToUpdate = [ADSI]$result.path
    $computerToUpdate.Description = $description

    I've gone into the registry on the machine I just built and the Description field is there and it does contain data. 

    It does not seem to be running since nothing ever gets moved.   My real question is this:

    the .\ sourcing in this command:  C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy bypass -file .\MoveAD.ps1

    how does it know where to call the script from?   Do I need to specify a different path and if so which path?  
    Tuesday, May 16, 2017 6:13 PM


All replies