Powershell Remote Pre-Staging to wds

Home Forums Scripting PowerShell Powershell Remote Pre-Staging to wds

This topic contains 5 replies, has 4 voices, and was last updated by  Anonymous 1 year, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts

  • Skl816405
    Member
    #167031

    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 = “WDSadministrator”
    $Password = “PassWord”
    $Pass = ConvertTo-SecureString $Password -asPlainText -force
    $Cred = new-object System.Management.Automation.PSCredential($UserName, $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 “Bootx64ImagesLiteTouchPE_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 = “WDSadministrator”
    $Password = “PassWord”
    $Pass = ConvertTo-SecureString $Password -asPlainText -force
    $Cred = new-object System.Management.Automation.PSCredential($UserName, $pass)

    Invoke-Command -ComputerName WDS -ScriptBlock { New-WdsClient -DeviceID “ComputerGUID” -DeviceName “ComputerName” -BootImagePath “Bootx64ImagesLiteTouchPE_x64.wim” } -credential $Cred

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

    powershell version 5.0

    Best regards to you all


    Ossian
    Moderator
    #191670

    Have you checked that your variable $DevGuid contains the correct value?


    JeremyW
    Moderator
    #271484

    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.


    Anonymous
    #372049

    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.


    JeremyW
    Moderator
    #271488

    Rick, when I run the command it’s returned as a string… :???:

    (Get-WmiObject Win32_NetworkAdapter -Filter “netenabled = true” | select -Expand Guid | select -First 1).GetType()[/CODE][CODE](Get-WmiObject Win32_NetworkAdapter -Filter “netenabled = true” | select -Expand Guid | select -First 1).GetType()[/CODE]


    Anonymous
    #372050

    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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.