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($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 “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($UserName, $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

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

and the BootImagePath must be full path not relative.

Thank you very much (Sam Boutros) you are the best, it worked.

have a very nice day

best regards to you all :slight_smile: