Announcement

Collapse
No announcement yet.

Powershell Remote Pre-Staging to wds

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Powershell Remote Pre-Staging to wds

    Powershell Remote Pre-Staging to wds



    I,m having problem in my powershell script I,m trying to remote prestage a client to my wds, i hope someone can help

    this is the secript

    ================================================== ==========

    $Username = "WDS\administrator"
    $Password = "PassWord"
    $Pass = ConvertTo-SecureString $Password -asPlainText -force
    $Cred = new-object System.Management.Automation.PSCredential($UserNam e, $pass)

    $DevGuid = Get-WmiObject Win32_NetworkAdapter -Filter "netenabled = true" | Select -Expand Guid
    $DevNam = Get-WmiObject -Class Win32_Bios | Select -Expand SerialNumber

    Invoke-Command -ComputerName WDS -ScriptBlock { New-WdsClient -DeviceID $DevGuid -DeviceName $DevNam -BootImagePath "Boot\x64\Images\LiteTouchPE_x64.wim" } -credential $Cred

    ================================================== ==========

    When i run the secript i get this error message.

    (Cannot validate argument on parameter 'DeviceID'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. )



    First i hade this command and it worked well

    ================================================== ===========

    $Username = "WDS\administrator"
    $Password = "PassWord"
    $Pass = ConvertTo-SecureString $Password -asPlainText -force
    $Cred = new-object System.Management.Automation.PSCredential($UserNam e, $pass)

    Invoke-Command -ComputerName WDS -ScriptBlock { New-WdsClient -DeviceID "ComputerGUID" -DeviceName "ComputerName" -BootImagePath "Boot\x64\Images\LiteTouchPE_x64.wim" } -credential $Cred

    ================================================== ===========


    powershell version 5.0

    Best regards to you all
    Last edited by Skl816405; 24th May 2017, 10:10.

  • #2
    Have you checked that your variable $DevGuid contains the correct value?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Also note that if you have multiple adapters that match the query Get-WmiObject Win32_NetworkAdapter -Filter "netenabled = true" then your variable would be an array of GUIDs and not a string. So you may need to do some additional filtering.
      Regards,
      Jeremy

      Network Consultant/Engineer
      Baltimore - Washington area and beyond
      www.gma-cpa.com

      Comment


      • #4
        Pre-staging a PC requires filling the AD attribute 'netbootGUID'. When you do it by hand, you type in the MAC address without any separators, and 20 zeros in front of it. If you try to read that back out later on, it is not a string, it's a system object type [GUID], that must be converted to a string to be used in code. I know this because I have a wake-on-LAN script that does exactly that--reads the netbootGUID value and parses the MAC address from that for broadcast on the appropriate subnet (there's other prep as well before the broadcast, but that's not important here.) Do a search for converting between strings and [GUID] types and modify your code. I suspect the 'DeviceID' value goes to the attribute I named, but don't know for sure.
        *RicklesP*
        MSCA (2003/XP), Security+, CCNA

        ** Remember: credit where credit is due, and reputation points as appropriate **

        Comment


        • #5
          Rick, when I run the command it's returned as a string...

          Code:
          (Get-WmiObject Win32_NetworkAdapter -Filter "netenabled = true" | select -Expand Guid | select -First 1).GetType()
          Regards,
          Jeremy

          Network Consultant/Engineer
          Baltimore - Washington area and beyond
          www.gma-cpa.com

          Comment


          • #6
            Strange. When I run your one-line command on the PC I write this on, I get 4 columns: IsPublic, IsSerial, Name, and BaseType. The values for those are True, True, String and System.Object, so I wonder about the value you're trying to capture. Be that as it may, Ossian's question still stands: if you step through the code one line at a time, what value do you see for the $DevGuid variable, before execution of the Invoke-Command line with that variable? The WDS prestage info held in AD can be that GUID value, but you can always build another value as I described in my first post. Try reading the MAC address of the adapter as a string, and then stick 20 zeros on the front of it and store that value. But still let us know whether your variable is empty BEFORE the execution line where it's used.
            *RicklesP*
            MSCA (2003/XP), Security+, CCNA

            ** Remember: credit where credit is due, and reputation points as appropriate **

            Comment

            Working...
            X