Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## START
  2.  
  3. # warning: this script has been written by a complete moron.
  4.  
  5. ## Disable the firewall
  6. Wpeutil disablefirewall > $null
  7.  
  8. ## Set the path of curl (GPL distribuited)
  9. $curl="x:\windows\system32\curl.exe"
  10.  
  11. ## Get the MAC
  12. $mac=$(Get-WmiObject win32_networkadapterconfiguration -Filter ipenabled="true"|select -expandproperty macaddress|select-object -first 1).Tolower()
  13.  
  14. ## Optain the DHCP server (that is also the TFTP server)
  15. $foremanproxy=$(Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.DHCPEnabled -eq $true -and $_.DHCPServer -ne $null} | select -expandproperty DHCPServer|select-object -first 1)
  16. ## Change the mac to the format witht the dash instead of semicolons
  17. $mac=$mac -replace ":", "-"
  18.  
  19. ## Build the path to the pxelinux configuration
  20. $tftp='tftp://' + $foremanproxy + '/pxelinux.cfg/01-' + $mac
  21.  
  22. ## Build the commandline to retrive the TFTP
  23. $command=$curl + ' ' + $tftp + ' -o pxeconf.tmp'
  24.  
  25. ## Obtain the pxe configuration
  26. iex $command
  27.  
  28. ## Extract variables
  29. # Getting URL
  30. $URL=$(cat .\pxeconf.tmp|findstr.exe URL) -replace '.# URL=','' -replace ' ',''
  31.  
  32. ## Place it in an environment
  33.  
  34. ## Retrive the TOKEN
  35.  
  36. ## Get the unattended script
  37. $command=$curl + ' ' + $URL + ' -o unattended.xml'
  38. iex $command
  39.  
  40. ## END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement