Guest User

Untitled

a guest
Dec 2nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <#
  2. Bypass file for OEM OOBE Setup.
  3. Called from within Audit Mode.
  4. #>
  5.  
  6. param(
  7. [int] $TargetDisk = 0,
  8. [string] $NewBootWim = "$PSScriptRoot\Generic_x64.wim",
  9. [string] $UserName = 'MDTServer\MDTNonInteractive',
  10. [string] $Password = 'UnSecurePassword1234',
  11. [string] $BootType = 'x64',
  12. [string] $Target = 'h:'
  13. )
  14.  
  15. $ErrorActionPreference = 'stop'
  16.  
  17. #region Find the largest on-disk partition
  18. ###############################################################################
  19.  
  20. $TargetDrive = get-disk -Number $TargetDisk |
  21. Get-partition |
  22. Sort -Descending -Property Size |
  23. Select-Object -First 1 |
  24. Get-Volume |
  25. foreach-object { $_.DriveLetter + ':' }
  26.  
  27. # get a drive letter for the system partition
  28. get-disk -Number $TargetDisk |
  29. get-partition |
  30. where-object { -not $_.DriveLetter } |
  31. Where-Object Type -eq System |
  32. Add-PartitionAccessPath -AccessPath $Target
  33.  
  34. #endregion
  35.  
  36. #region Connect to a network share if Source is over the network...
  37. ###############################################################################
  38.  
  39. if ( -not ( test-path $NewBootWim ) ) {
  40.  
  41. if ( $newBootWim.StartsWith('\\') -and $UserName -and $Password ) {
  42. # COnnect to the network share.
  43. net use "$(split-path $NewBootWim)" /user:$UserName "$Password"
  44. }
  45. }
  46.  
  47. #endregion
  48.  
  49. #region Copy the Boot WIM
  50. ###############################################################################
  51.  
  52. new-item -ItemType directory -path $TargetDrive\Sources -Force -ErrorAction SilentlyContinue | Out-Null
  53. copy-item $NewBootWim $TargetDrive\Sources\Boot.wim
  54.  
  55. robocopy /e $PSScriptRoot\x64 $Target\ /xf bcd bcd.log
  56.  
  57. #endregion
  58.  
  59. #region Create a BCD entry
  60. ###############################################################################
  61.  
  62. Bcdedit /create "{ramdiskoptions}" /d "Ramdisk options"
  63. Bcdedit /set "{ramdiskoptions}" ramdisksdidevice boot
  64. Bcdedit /set "{ramdiskoptions}" ramdisksdipath \boot\boot.sdi
  65.  
  66. $Output = bcdedit -create /d "MYIT_OEMHack" /application OSLOADER
  67. $GUID = $output | %{ $_.split(' ')[2] }
  68.  
  69. bcdedit /set $Guid device "ramdisk=[$TargetDrive]\sources\boot.wim,{ramdiskoptions}"
  70. bcdedit /set $Guid osdevice "ramdisk=[$TargetDrive]\sources\boot.wim,{ramdiskoptions}"
  71. bcdedit /set $Guid path \windows\system32\boot\winload.efi
  72. bcdedit /set $Guid systemroot \windows
  73. bcdedit /set $Guid detecthal yes
  74. bcdedit /set $Guid winpe yes
  75. bcdedit /set $Guid ems no
  76. bcdedit /set $Guid isolatedcontext yes
  77.  
  78. Bcdedit /displayorder $Guid -addfirst
  79. Bcdedit /default $Guid
  80. Bcdedit /timeout 10
  81.  
  82. #endregion
  83.  
  84. #region Reboot
  85. ###############################################################################
  86.  
  87. write-host "DONE"
  88. shutdown -r -f -t 0
  89.  
  90. #endregion
Add Comment
Please, Sign In to add comment