Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## START
- # warning: this script has been written by a complete moron.
- ## Disable the firewall
- Wpeutil disablefirewall > $null
- ## Set the path of curl (GPL distribuited)
- $curl="x:\windows\system32\curl.exe"
- ## Get the MAC
- $mac=$(Get-WmiObject win32_networkadapterconfiguration -Filter ipenabled="true"|select -expandproperty macaddress|select-object -first 1).Tolower()
- ## Optain the DHCP server (that is also the TFTP server)
- $foremanproxy=$(Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.DHCPEnabled -eq $true -and $_.DHCPServer -ne $null} | select -expandproperty DHCPServer|select-object -first 1)
- ## Change the mac to the format witht the dash instead of semicolons
- $mac=$mac -replace ":", "-"
- ## Build the path to the pxelinux configuration
- $tftp='tftp://' + $foremanproxy + '/pxelinux.cfg/01-' + $mac
- ## Build the commandline to retrive the TFTP
- $command=$curl + ' ' + $tftp + ' -o pxeconf.tmp'
- ## Obtain the pxe configuration
- iex $command
- ## Extract variables
- # Getting URL
- $URL=$(cat .\pxeconf.tmp|findstr.exe URL) -replace '.# URL=','' -replace ' ',''
- ## Place it in an environment
- ## Retrive the TOKEN
- ## Get the unattended script
- $command=$curl + ' ' + $URL + ' -o unattended.xml'
- iex $command
- ## END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement