Advertisement
Guest User

WinPE40.ps1

a guest
May 30th, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # WinPE 4.0 toolset in PowerShell
  2. #
  3. # Original PowerShell functions from
  4. # <http://www.jbmurphy.com/2012/01/13/powershell-scripts-to-create-a-winpe-4-0-wimiso/>
  5. # <http://www.jbmurphy.com/2012/01/24/powershell-script-to-make-a-winpe-usb-drive/>
  6. #
  7. # Change the $workdir argument to the place you want to use as your working directory
  8. #
  9. # Note that you must be running PowerShell as an administrator for this to work!
  10. #
  11. # Note that you can dot-source this file like `. winpe40.ps1`. It will display the
  12. # error message about not invoking it correctly, but you'll be able to use my
  13. # aliases for dismexe and imagexexe and stuff, and my functions.
  14. # TODO: Should probably make dot sourcing suck less. It's really useful.
  15.  
  16. Param (
  17. #    [Parameter(Position=0,Mandatory=$true)]
  18. [string]$Action,
  19. [string]$xmlfile="D:\winbacore.xml"
  20. )
  21. # Param (
  22. #     [Parameter(Position=0,Mandatory=$true)]
  23. #         [string]$Action,
  24. # #    [Parameter(Position=1,Mandatory=$true)]
  25. #     [Parameter(Position=1)]
  26. #         [ValidateSet('x86', 'amd64')]
  27. #         [string]$OSArchitecture = "x86",
  28. #     [Parameter(Position=2)]
  29. #         [string]$WorkDir = "D:\pe40"
  30. # )
  31. $cmdname = $myinvocation.MyCommand
  32.  
  33.  
  34. # required for {get,set}-privilege
  35. write-host ("Importing pscx module, this will take a minute...")
  36. import-module pscx
  37.  
  38.  
  39. if (-not (test-path $xmlfile)) {
  40.     write-error ("No such file '$xmlfile'")
  41.     return $null
  42. }
  43. $config = [xml](get-content $xmlfile)
  44. $OSArchitecture = $config.winpe.configuration.architecture
  45. $distlang = $config.winpe.configuration.distlang
  46. $WorkDir = $config.winpe.configuration.workdir
  47. $logfile = "$workdir\winpe.log"
  48. $WimFile="$workdir\ISO\sources\boot.wim"
  49. $mountdir = "$workdir\mount"
  50. $winsrc = $config.winpe.source.path
  51. $srcmountdir = "$workdir\srcmount"
  52. $vmxfile = $config.winpe.vmware.vmxpath
  53.  
  54. $wadkdir = "${env:ProgramFiles(x86)}\Windows Kits\8.0\Assessment and Deployment Kit"
  55.  
  56. function Write-Log {
  57.     # if you want to see logs to the console, just comment out the redirection
  58.     write-output ($args) >>$logfile
  59. }
  60.  
  61. # NOTE! If you want to log to the console instead of a file, don't edit this function - edit write-log, above.
  62. function Echoexec-Expression {
  63.     Param($whatif)
  64.     write-log ("#: " + $args.count + "`r`nargs: $args")
  65.     $expression = ""
  66.     foreach ($a in $args) {
  67.         if ("$a".contains(" ")) {
  68.             $expression += "`"$a`" "
  69.         }
  70.         else {
  71.             $expression += "$a "
  72.         }
  73.     }
  74.     if (-not ($whatif)) {
  75.         invoke-expression "$expression"
  76.     }
  77. }
  78. set-alias echoexec echoexec-expression
  79.  
  80. # alias setup
  81. set-alias bcdbootexe "$wadkdir\Deployment Tools\$OSArchitecture\BCDBoot\bcdboot.exe"
  82. set-alias bcdeditexe "$wadkdir\Deployment Tools\$OSArchitecture\BCDBoot\bcdedit.exe"
  83. set-alias bootsectexe "$wadkdir\Deployment Tools\$OSArchitecture\BCDBoot\bootsect.exe"
  84. set-alias dismexe "$wadkdir\Deployment Tools\$OSArchitecture\DISM\dism.exe"
  85. set-alias imagexexe "$wadkdir\Deployment Tools\$OSArchitecture\DISM\imagex.exe"
  86. set-alias pkgmgrexe "$wadkdir\Deployment Tools\$OSArchitecture\DISM\pkgmgr.exe"
  87. set-alias wimservexe "$wadkdir\Deployment Tools\$OSArchitecture\DISM\wimserv.exe"
  88. set-alias wimmountadksetupexe "$wadkdir\Deployment Tools\$OSArchitecture\DISM\winmountadksetup$OSArchitecture.exe"
  89. set-alias oscdimgexe "$wadkdir\Deployment Tools\$OSArchitecture\Oscdimg\oscdimg.exe"
  90. set-alias imagecatexe "$wadkdir\Deployment Tools\WSIM\imagecat.exe"
  91. set-alias imgmgrexe "$wadkdir\Deployment Tools\WSIM\imgmgr.exe"
  92. set-alias helpindexerexe "$wadkdir\Deployment Tools\HelpIndexer\helpindexer.exe"
  93.  
  94. function WinPE-MakePEDirectory {
  95.     remove-item -recurse -force "$workdir"
  96.     New-Item $workdir\ISO\sources -type directory -force
  97.     New-Item $mountdir -type directory -force
  98.     copy-item -recurse "${env:ProgramFiles(x86)}\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\$OSArchitecture\en-us\winpe.wim" "$workdir\ISO\sources\boot.wim"
  99.     copy-item -recurse "${env:ProgramFiles(x86)}\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\$OSArchitecture\Media\*" "$workdir\ISO\"
  100.     copy-item -recurse "${env:ProgramFiles(x86)}\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\$OSArchitecture\Oscdimg\etfsboot.com" "$workdir\"
  101. }
  102.  
  103. function WinPE-Mount {
  104.     dismexe /Mount-Wim /WimFile:$WimFile /index:1 /MountDir:$mountdir
  105. }
  106.  
  107. function WinPE-AddPAckages {
  108.     $OCsPATH="${env:ProgramFiles(x86)}\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\$OSArchitecture\WinPE_OCs"
  109.  
  110.     foreach ($syspkg in $config.winpe.packages.system) {
  111.         if ($syspkg) {
  112.             $packagename = $syspkg.filename
  113.             $packagepath = "$OCsPATH\$packagename"
  114.        
  115.             if (-not (test-path $packagepath)) {
  116.                 write-error ("Expected system package '$packagename' to be found at path '$packagepath', but there was no package found there")
  117.             }
  118.             else {
  119.                 Echoexec-Expression dismexe /image:$mountdir /add-package /packagepath:$packagepath
  120.             }
  121.         }
  122.     }
  123.  
  124.     foreach ($userpkg in $config.winpe.packages.user) {
  125.         if ($userpkg) { # not sure why but we get a null one every once in a while
  126.             $packagepath = $userpkg.filepath
  127.             if (-not (test-path $packagepath)) {
  128.                 write-error ("There was no user package at path '$packagepath'.")
  129.             }
  130.             else {
  131.                 Echoexec-Expression dismexe /image:$mountdir /add-package /packagepath:$packagepath
  132.             }
  133.         }
  134.     }
  135.  
  136.     foreach ($include in $config.winpe.include) {
  137.         if ($include) {
  138.             $src = $include.source
  139.             $dst = $mountdir + $include.destination
  140.             if (-not (test-path $src)) {
  141.                 write-error ("Supposed to copy '$src' to $dst' but no such source.")
  142.             }
  143.             else {
  144.                 Echoexec-Expression mkdir -force $dst
  145.                 Echoexec-Expression copy-item -recurse -force $src $dst
  146.             }
  147.         }
  148.     }
  149. }
  150.  
  151. function WinPE-MountSource {
  152.     mkdir -force $srcmountdir
  153.     dismexe /Mount-Wim /WimFile:$winsrc\sources\install.wim /index:1 /MountDir:$srcmountdir
  154. }
  155. function WinPE-CancelmountSource {
  156.     dismexe /unmount-Wim /MountDir:$srcmountdir /discard
  157. }
  158. set-alias WinPE-UnmountSource WinPE-CancelmountSource
  159.  
  160. function WinPE-Cancelmount {
  161.     dismexe /unmount-Wim /MountDir:$mountdir /discard
  162. }
  163.  
  164. function WinPE-CommitUnMount {
  165.     dismexe /unmount-Wim /MountDir:$mountdir /Commit
  166. }
  167. set-alias WinPE-Unmount WinPE-CommitUnMount
  168.  
  169. function WinPE-MakeISO {
  170.     & oscdimgexe -m -n "-b$workdir\etfsboot.com" $workdir\ISO $workdir\winpe_$OSArchitecture.iso
  171. }
  172.  
  173. # this function doesn't work at all! fucking VPC doesn't do Windows 8 lolololol
  174. function WinPE-StartVPCVM {
  175.     # this doesn't work if you're running x86 powershell on x64 windows fuck
  176.     start-process "C:\Windows\System32\vmwindow.exe" "$config.winpe.virtualpc.vmcxpath"
  177. }
  178. function WinPE-StartVMwareVM {
  179.     start-process "${env:programfiles(x86)}\VMware\VMWare Player\vmplayer.exe" `""${vmxfile}"`"
  180. }
  181. set-alias WinPE-StartVM WinPE-StartVMwareVM
  182.  
  183.  
  184.  
  185. # Steal-FullControlPrivs
  186. #
  187. # - *must* use takeown.exe otherwise it won't work
  188. # - You need PSCX for {get,set}-privilege
  189. #
  190. # <http://blog.salamandersoft.co.uk/index.php/2009/10/setting-the-owner-of-files-and-directories-in-c/>
  191. # <http://stackoverflow.com/questions/488310/can-i-change-the-owner-of-the-file-saved-through-iis-with-asp-net)
  192. # <http://stackoverflow.com/questions/8216510/how-do-i-change-the-owner-of-a-folder-with-powershell-when-get-acl-returns-acce>
  193. $myprivs=get-privilege
  194. $myprivs.enable("SeTakeOwnershipPrivilege")
  195. $myprivs.enable("SeBackupPrivilege")
  196. $myprivs.enable("SeRestorePrivilege")
  197. set-privilege $myprivs
  198. $MyIdentity = [Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
  199. $MyAccount = New-Object System.Security.Principal.NTAccount($myidentity.identity.name)
  200. function Steal-FullControlPrivs {
  201.    param([parameter(Position=0, Mandatory=$true)] $path)
  202.    # $path = "D:\winbacore2\mount\Program Files\Common Files\System\ado\msado15.dll"
  203.    $oldacl = get-acl $path
  204.    write-log ("oldacl: Owner: " + $oldacl.Owner + "`r`nAccess:")
  205.    foreach ($r in $oldacl.Access) {
  206.        write-log ("    User: " + $r.IdentityReference.Value + " // " + $r.AccessControlType + " // Rights: " + $r.Filesystemrights)
  207.    }
  208.    echoexec-expression start-process -nonewwindow -wait -RedirectStandardOutput "$logfile" -filepath $env:windir\system32\takeown.exe -argumentlist @("/f","`"$path`"")
  209.  
  210.     $newacl = get-acl $path
  211.     $ar = New-Object system.security.AccessControl.FileSystemAccessRule($MyAccount, "FullControl", "Allow")
  212.     $newacl.addaccessrule($ar)
  213.     echoexec-expression set-acl -path $path -aclobject $newacl
  214.  
  215.     $OldOwnerAccount = New-Object System.Security.Principal.NTAccount($oldacl.Owner)
  216.     $newacl.setowner($OldOwnerAccount)
  217.     #echoexec-expression set-acl -path $path -aclobject $newacl
  218.     echoexec-expression set-acl -path $path -aclobject $newacl
  219.     write-log ("Final ACL: Owner: " + $newacl.Owner + "`r`nAccess:")
  220.     foreach ($r in $newacl.Access) {
  221.         write-log ("    User: " + $r.IdentityReference.Value + " // " + $r.AccessControlType + " // Rights: " + $r.Filesystemrights)
  222.     }
  223. }
  224.  
  225. function WinPE-AddExplorer {
  226.     param([switch]$whatif)
  227.     if (-not (test-path $srcmountdir\Windows\explorer.exe)) {
  228.         write-error ("There does not appear to be a source image mounted at $srcmountdir. Failed.")
  229.         return
  230.     }
  231.     if ($whatif) {
  232.         $w = "-whatif"
  233.     }
  234.     else {
  235.         $w = ""
  236.     }
  237.  
  238.    
  239.     # Make the directories
  240.     $dirs = @("$mountdir\Users\Administrator","$mountdir\ProgramData\Microsoft","$mountdir\ProgramData\Microsoft\Windows",
  241.               "$mountdir\ProgramData\Microsoft\Windows\DeviceMetadataStore","$mountdir\Windows\Branding\Basebrd\$distlang","$mountdir\Windows\Branding\Basebrd\en-US",
  242.               "$mountdir\Windows\Branding\ShellBrd","$mountdir\Windows\en-US","$mountdir\Windows\system32\en-US",
  243.               "$mountdir\Windows\AppPatch","$mountdir\Windows\$distlang","$mountdir\Windows\System32\$distlang",
  244.               "$mountdir\Windows\IME\$distlang","$mountdir\Program Files\Common Files\Microsoft Shared\ink\$distlang","$mountdir\Windows\winsxs\Manifests",
  245.               "$mountdir\Windows\system32\config\Systemprofile\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch","$mountdir\Windows\servicing","$mountdir\Windows\Resources",
  246.               "$mountdir\Windows\web","$mountdir\Windows\system32\oobe","$mountdir\Program Files\Internet Explorer\")
  247.     foreach ($d in $dirs) {
  248.         echoexec-expression $w mkdir -force $d
  249.     }
  250.  
  251.     $s32files = @("oobe","dwm.exe","hdwwiz.*","wow*","*cpl.dll","*cpl","des*","dhcp*.dll","dm*","ie*","msv*.dll",
  252.                   "net*.dll","ole*.dll","PnP*.dll","SystemProperties*","wmd*.dll","*.cpl.mui","des*.mui","dhcp*.dll.mui",
  253.                   "network*.dll.mui","net*.dll.mui","old*.dll.mui","AuxiliaryDisplayApi.dll","AuxiliaryDisplayClassInstaller.dll","avicap.dll","avicap32.dll",
  254.                   "pnp*.mui","systempropertie*.exe.mui","actxprxy.dll","adsldp.dll","advapi32.dll","apphelp.dll","atl.dll",
  255.                   "avifil32.dll","avifile.dll","avrt.dll","AxInstSv.dll","browseui.dll",
  256.                   "catsrv.dll","catsrvps.dll","catsrvut.dll","certEnroll.dll","clbcatq.dll","colbact.dll",
  257.                   "collab.cpl","comctl32.dll","comm.drv","comrepl.dll","comres.dll",
  258.                   "comsnap.dll","comsvcs.dll","comuid.dll","control.exe","corpol.dll","crtdll.dll",
  259.                   "cscapi.dll","cttune.exe","d3d9.dll","dbghelp.dll","dbgeng.dll",
  260.                   "dcomcnfg.exe","devmgr.dll","diskcopy.dll","display.dll","DisplaySwitch.exe","dllhost.exe",
  261.                   "dllhst3g.exe","dsound.dll","dwm.exe","dwmapi.dll","Dwmredir.dll",
  262.                   "efsadu.dll","es.dll","eventcreate.exe","eventvwr.exe","fwpuclnt.dll","hlink.dll",
  263.                   "ie4uinit.exe","ieui.dll","ieuinit.inf","imgutil.dll","inetcomm.dll",
  264.                   "inetcpl.cpl","intl.cpl","IoLogMsg.dll","IPHLPAPI.DLL","jscript.dll","jsproxy.dll",
  265.                   "locale.nls","lpk.dll","lpksetup.exe","lpksetupproxyserv.dll","main.cpl",
  266.                   "mfcsubs.dll","mmdevapi.dll","mmsys.cpl","MSACM32.dll","mscories.dll","msoert2.dll",
  267.                   "msfeeds.dll","mshtml.dll","msi.dll","mstime.dll","msoert2.dll",
  268.                   "msrating.dll","msxml3.dll","msxml3r.dll","msxml6.dll","msxml6r.dll","mtstocom.exe",
  269.                   "mtxdm.dll","mtxex.dll","mtxlegih.dll","ndfapi.dll","normaliz.dll",
  270.                   "nsi.dll","ntdll.dll","objsel.dll","occache.dll","osbaseln.dll","pdh.dll",
  271.                   "printui.dll","puiapi.dll","quartz.dll","query.dll","rcphttp.dll",
  272.                   "rstrtmgr.dll","secur32.dll","sens.dll","Shwebsvc.dll","shimgvw.dll","shlwapi.dll",
  273.                   "Shsvcs.dll","shunimpl.dll","SLC.dll","stclient.dll","swprv.dll",
  274.                   "sysdm.cpl","tdh.dll","themecpl.dll","themeui.dll","thumbcache.dll","timedate.cpl",
  275.                   "tracerpt.exe","TSTheme.exe","txflog.dll","UIAutomationCore.dll","urlmon.dll",
  276.                   "user.exe","user32.dll","uxsms.dll","uxtheme.dll","van.dll","vaultcli.dll",
  277.                   "vbscript.dll","verclsid.exe","WcsPlugInService.dll","wdi.dll","wecapi.dll",
  278.                   "wecsvc.dll","wecutil.exe","wermgr.exe","wevtsvc.dll","wevtutil.exe","WindowsCodecs.dll",
  279.                   "WindowsCodecsExt.dll","wininet.dll","wininet.dll","winnsi.dll","winrnr.dll",
  280.                   "ws2_32.dll","rshx32.dll","aclui.dll","ntshrui.dll","shpafact.dll","twext.dll")
  281.  
  282.     $distlangfiles = @("rshx32.dll.mui","aclui.dll.mui","ntshrui.dll.mui","shpafact.dll.mui","twext.dll.mui",
  283.                   "actxprxy.dll.mui","adsldp.dll.mui","advapi32.dll.mui","apphelp.dll.mui","appwiz.cpl.mui","atl.dll.mui",
  284.                   "avrt.dll.mui","browseui.dll.mui","cdosys.dll.mui","clbcatq.dll.mui","collab.cpl.mui",
  285.                   "comctl32.dll.mui","control.exe.mui","cscript.exe.mui","cscui.dll.mui","cttune.exe.mui","des*.mui",
  286.                   "diskcopy.dll.mui","dnsapi.dll.mui","duser.dll.mui","dwmapi.dll.mui","Dwmredir.dll.mui",
  287.                   "dxtmsft.dll.mui","dxtrans.dll.mui","Explorer.exe.mui","ExplorerFrame.dll.mui","gdi32.dll.mui","gpscript.exe.mui",
  288.                   "hdwwiz.cpl.mui","ie4uinit.exe.mui","ieuinit.inf.mui","imm32.dll.mui","inetcpl.cpl.mui",
  289.                   "intl.cpl.mui","IPHLPAPI.DLL.mui","jscript.dll.mui","jsproxy.dll.mui","kernel32.dll.mui","main.cpl.mui",
  290.  
  291.                   "mferror.dll.mui","mmsys.cpl.mui","mscories.dll.mui","msctf.dll.mui","msi.dll.mui",
  292.                   "msimsg.dll.mui","msvcrt.dll.mui","ndfapi.dll.mui","netplwiz.dll.mui","normaliz.dll.mui","nsi.dll.mui",
  293.                   "ntdll.dll.mui","objsel.dll.mui","osbaseln.dll.mui","powrprof.dll.mui","propsys.dll.mui",
  294.                   "rasauto.dll.mui","rpcrt4.dll.mui","secur32.dll.mui","sens.dll.mui","setupapi.dll.mui","shdocvw.dll.mui",
  295.                   "shell32.dll.mui","shellstyle.dll.mui","shlwapi.dll.mui","Shsvcs.dll.mui","Shwebsvc.dll.mui",
  296.                   "SLC.dll.mui","sysdm.cpl.mui","themecpl.dll.mui","themeui.dll.mui","thumbcache.dll.mui","timedate.cpl.mui",
  297.                   "TSTheme.exe.mui","urlmon.dll.mui","user32.dll.mui","uxtheme.dll.mui","van.dll.mui",
  298.                   "vbscript.dll.mui","verclsid.exe.mui","wdi.dll.mui","WindowsCodecs.dll.mui","WindowsCodecsExt.dll.mui","wininet.dll.mui",
  299.                   "winnsi.dll.mui","winrnr.dll.mui","ws2_32.dll.mui","xmllite.dll.mui")
  300.  
  301.     foreach ($f in (gci $srcmountdir\Windows\system32\* -include $s32files)) {
  302.         $destlocation = "$mountdir\Windows\system32\" + $f.Name # $f.Name because $f is the *full path*
  303.         write-log "About to attempt to copy $f into $destlocation"
  304.         #if (test-path $destlocation 2>&1 > $null) {
  305.         #    write-log "Path at $destlocation seems to already exist, trying to steal full control..."
  306.             Echoexec-Expression $w Steal-FullControlPrivs $destlocation
  307.         #}
  308.         Echoexec-Expression $w copy-item -force -recurse $f $mountdir\Windows\system32
  309.     }
  310.  
  311.     foreach ($f in (gci $srcmountdir\Windows\system32\$distlang\* -include $distlangfiles)) {
  312.         $destlocation = "$mountdir\Windows\system32\$distlang\" + $f
  313.         #if (test-path $destlocation 2>&1 > $null) {
  314.         #    write-log "Path at $destlocation seems to already exist, trying to steal full control..."
  315.             Echoexec-Expression $w Steal-FullControlPrivs $destlocation
  316.         #}
  317.         Echoexec-Expression $w copy-item -force -recurse $f $mountdir\Windows\system32\$distlang
  318.     }
  319.  
  320.     Echoexec-Expression $w copy-item -force -recurse `
  321.         "$srcmountdir\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Shows Desktop.lnk" `
  322.         "$mountdir\Windows\System32\config\Systemprofile\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch"
  323.  
  324.     Echoexec-Expression $w copy-item -force -recurse "$srcmountdir\Program Files\Internet Explorer\ieshims.dll" "$mountdir\Program Files\Internet Explorer\ieshims.dll"
  325.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\ProgramData\Microsoft\Windows\DeviceMetadataStore $mountdir\ProgramData\Microsoft\Windows\
  326.  
  327.  
  328.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\AppPatch\sysmain.sdb $mountdir\Windows\AppPatch
  329.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\Branding\Basebrd\basebrd.dll $mountdir\Windows\Branding\Basebrd
  330.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\Branding\ShellBrd\shellbrd.dll $mountdir\Windows\Branding\ShellBrd
  331.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\explorer.exe $mountdir\Windows
  332.  
  333.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\Branding\Basebrd\$distlang\basebrd.dll.mui $mountdir\Windows\Branding\Basebrd\$distlang
  334.     Echoexec-Expression $w copy-item -force -recurse $srcmountdir\Windows\$distlang\explorer.exe.mui $mountdir\Windows\$distlang
  335.  
  336. }
  337.  
  338.  
  339. $helptext = "
  340. $cmdname is a script which automates part of the setup process for WinPE 4.0 / WADK.
  341. It requires that WADK for WinPE 4 (Windows 8) is installed.
  342. There are subcommands that perform different steps in the process:
  343.  
  344.    $cmdname mkdir
  345.    $cmdname mount
  346.  
  347.    $cmdname addpackages
  348.    $cmdname unmount -OR- $cmdname cancelmount
  349.    $cmdname makeiso
  350.  
  351. You can get help with the command:
  352.  
  353.    $cmdname help
  354.  
  355. You can perform all of the steps with the command:
  356.  
  357.    $cmdname buildall
  358. "
  359.  
  360. switch ($action) {
  361.     "mkdir" {
  362.         WinPE-MakePEDirectory
  363.     }
  364.     "mount" {
  365.         WinPE-Mount
  366.     }
  367.     "addpackages" {
  368.         WinPE-AddPackages
  369.     }
  370.     "unmount" {
  371.         WinPE-UnMount
  372.     }
  373.     "cancelmount" {
  374.         WinPE-Cancelmount
  375.     }
  376.     "makeiso" {
  377.         WinPE-MakeISO
  378.     }
  379.     "help" {
  380.         write-host $helptext
  381.     }
  382.     "buildall" {
  383.         WinPE-MakePEDirectory
  384.         WinPE-Mount
  385.         WinPE-AddPackages
  386.         WinPE-UnMount
  387.         WinPE-MakeISO
  388.     }
  389.     "startvm" {
  390.         WinPE-StartVM
  391.     }
  392.     "addexplorer" {
  393.         WinPE-AddExplorer
  394.     }
  395.     default {
  396.         write-host ("Wrong action $action...")
  397.         write-host ($helptext)
  398.     }
  399. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement