赞
踩
WindowsServer.Json
- {
-
- "builders": [
-
- {
- "type": "hyperv-iso",
- "communicator": "winrm",
- "disk_size": 61440,
- "memory": 2048,
- "floppy_files": [
- "{{template_dir}}/setup/"
- ],
- "guest_additions_mode": "disable",
- "headless": false,
- "iso_url": "file://F:\\SOFTWARE\\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso",
- "iso_checksum": "c1f8c8325e88f4687eabc4c60a6c3fcb",
- "winrm_username": "vagrant",
- "winrm_password": "vagrant",
- "winrm_timeout": "6h"
-
-
- }
- ],
- "provisioners": [
- {
- "type": "windows-shell",
- "inline": ["dir c:\\"]
- }
- ]
- }
-
Autounattend.xml
- <?xml version="1.0" encoding="utf-8"?>
- <unattend xmlns="urn:schemas-microsoft-com:unattend">
- <settings pass="windowsPE">
- <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SetupUILanguage>
- <UILanguage>zh-CN</UILanguage>
- </SetupUILanguage>
- <InputLocale>zh-CN</InputLocale>
- <SystemLocale>zh-CN</SystemLocale>
- <UILanguage>zh-CN</UILanguage>
- <UILanguageFallback>zh-CN</UILanguageFallback>
- <UserLocale>zh-CN</UserLocale>
- </component>
- <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <DiskConfiguration>
- <Disk wcm:action="add">
- <CreatePartitions>
- <CreatePartition wcm:action="add">
- <Type>Primary</Type>
- <Order>1</Order>
- <Size>350</Size>
- </CreatePartition>
- <CreatePartition wcm:action="add">
- <Order>2</Order>
- <Type>Primary</Type>
- <Extend>true</Extend>
- </CreatePartition>
- </CreatePartitions>
- <ModifyPartitions>
- <ModifyPartition wcm:action="add">
- <Active>true</Active>
- <Format>NTFS</Format>
- <Label>boot</Label>
- <Order>1</Order>
- <PartitionID>1</PartitionID>
- </ModifyPartition>
- <ModifyPartition wcm:action="add">
- <Format>NTFS</Format>
- <Label>Windows 2016</Label>
- <Letter>C</Letter>
- <Order>2</Order>
- <PartitionID>2</PartitionID>
- </ModifyPartition>
- </ModifyPartitions>
- <DiskID>0</DiskID>
- <WillWipeDisk>true</WillWipeDisk>
- </Disk>
- </DiskConfiguration>
- <ImageInstall>
- <OSImage>
- <InstallFrom>
- <MetaData wcm:action="add">
- <Key>/IMAGE/NAME</Key>
- <Value>Windows Server 2016 SERVERDATACENTER</Value>
- </MetaData>
- </InstallFrom>
- <InstallTo>
- <DiskID>0</DiskID>
- <PartitionID>2</PartitionID>
- </InstallTo>
- </OSImage>
- </ImageInstall>
- <UserData>
- <!-- Product Key from https://www.microsoft.com/de-de/evalcenter/evaluate-windows-server-technical-preview?i=1 -->
- <ProductKey>
- <!-- Do not uncomment the Key element if you are using trial ISOs -->
- <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs -->
- <Key>6CNGG-BJP34-H923Y-6DMWR-37BMF</Key>
- <WillShowUI>OnError</WillShowUI>
- </ProductKey>
- <AcceptEula>true</AcceptEula>
- <FullName>Vagrant</FullName>
- <Organization>Vagrant</Organization>
- </UserData>
- </component>
- </settings>
- <settings pass="specialize">
- <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <OEMInformation>
- <HelpCustomized>false</HelpCustomized>
- </OEMInformation>
- <ComputerName>vagrant-2016</ComputerName>
- <TimeZone>China Standard Time</TimeZone>
- <RegisteredOwner/>
- </component>
- <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
- </component>
- <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <IEHardenAdmin>false</IEHardenAdmin>
- <IEHardenUser>false</IEHardenUser>
- </component>
- <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
- </component>
- <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SkipAutoActivation>true</SkipAutoActivation>
- </component>
- <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <RunSynchronous>
- <RunSynchronousCommand wcm:action="add">
- <Order>1</Order>
- <Description>Set Execution Policy 64 Bit</Description>
- <Path>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</Path>
- </RunSynchronousCommand>
- <RunSynchronousCommand wcm:action="add">
- <Order>2</Order>
- <Description>Set Execution Policy 32 Bit</Description>
- <Path>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</Path>
- </RunSynchronousCommand>
- <!-- <RunSynchronousCommand wcm:action="add">
- <Order>3</Order>
- <Description>Disable WinRM</Description>
- <Path>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1</Path>
- </RunSynchronousCommand> -->
- </RunSynchronous>
- </component>
- </settings>
- <settings pass="oobeSystem">
- <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <AutoLogon>
- <Password>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </Password>
- <Enabled>true</Enabled>
- <Username>vagrant</Username>
- </AutoLogon>
- <FirstLogonCommands>
- <SynchronousCommand wcm:action="add">
- <Order>1</Order>
- <CommandLine>cmd.exe /c a:\vmtools.cmd</CommandLine>
- <RequiresUserInput>true</RequiresUserInput>
- </SynchronousCommand>
- </FirstLogonCommands>
- <OOBE>
- <HideEULAPage>true</HideEULAPage>
- <HideLocalAccountScreen>true</HideLocalAccountScreen>
- <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
- <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
- <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
- <NetworkLocation>Home</NetworkLocation>
- <ProtectYourPC>1</ProtectYourPC>
- </OOBE>
- <UserAccounts>
- <AdministratorPassword>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </AdministratorPassword>
- <LocalAccounts>
- <LocalAccount wcm:action="add">
- <Password>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </Password>
- <Group>administrators</Group>
- <DisplayName>Vagrant</DisplayName>
- <Name>vagrant</Name>
- <Description>Vagrant User</Description>
- </LocalAccount>
- </LocalAccounts>
- </UserAccounts>
- <RegisteredOwner />
- </component>
- </settings>
- <settings pass="offlineServicing">
- <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <EnableLUA>false</EnableLUA>
- </component>
- </settings>
- <cpi:offlineImage cpi:source="wim:c:/wim/install.wim#Windows Server 2012 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
- </unattend>
输出:
- F:\packer-hyperv-win2016>packer.exe build WindowsServer.Json
- Warning: Warning when preparing build: "hyperv-iso"
-
- A shutdown_command was not specified. Without a shutdown command, Packer will forcibly halt the virtual machine, which may result in data loss. hyperv-iso: output will be in this color. ==> hyperv-iso: Creating build directory... ==> hyperv-iso: Retrieving ISO
- ==> hyperv-iso: Trying file://F:\SOFTWARE\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso
- ==> hyperv-iso: Trying file://F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso?checksum=md5%3Ac1f8c8325e88f4687eabc4c60a6c3fcb
- ==> hyperv-iso: file://F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso?checksum=md5%3Ac1f8c8325e88f4687eabc4c60a6c3fcb => F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso ==> hyperv-iso: Creating floppy disk... hyperv-iso: Copying files flatly from floppy_files hyperv-iso: Copying directory: F:\packer-hyperv-win2016/setup/ hyperv-iso: Adding file: F:\packer-hyperv-win2016\setup\Autounattend.xml
- hyperv-iso: Adding file: F:\packer-hyperv-win2016\setup\vmtools.cmd
- hyperv-iso: Done copying files from floppy_files
- hyperv-iso: Collecting paths from floppy_dirs hyperv-iso: Resulting paths from floppy_dirs : [] hyperv-iso: Done copying paths from floppy_dirs hyperv-iso: Copying files from floppy_content hyperv-iso: Done copying files from floppy_content ==> hyperv-iso: Creating switch 'packer-hyperv-iso' if required...
- ==> hyperv-iso: switch 'packer-hyperv-iso' already exists. Will not delete on cleanup...
- ==> hyperv-iso: Creating virtual machine...
- ==> hyperv-iso: Enabling Integration Service...
- ==> hyperv-iso: Mounting os dvd drive F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso ...
- ==> hyperv-iso: Mounting floppy drive...
- ==> hyperv-iso: Skipping mounting Integration Services Setup Disk...
- ==> hyperv-iso: Mounting secondary DVD images...
- ==> hyperv-iso: Configuring vlan...
- ==> hyperv-iso: Determine Host IP for HyperV machine...
- ==> hyperv-iso: Host IP for the HyperV machine: 169.254.10.91
- ==> hyperv-iso: Attempting to connect with vmconnect...
- ==> hyperv-iso: Starting the virtual machine...
- ==> hyperv-iso: Waiting 10s for boot...
- ==> hyperv-iso: Typing the boot command...
- ==> hyperv-iso: Waiting for WinRM to become available...
- Cancelling build after receiving interrupt
- ==> hyperv-iso: Disconnecting from vmconnect...
- ==> hyperv-iso: Cleanup floppy drive...
- ==> hyperv-iso: Clean up os dvd drive...
- ==> hyperv-iso: Unregistering and deleting virtual machine...
- ==> hyperv-iso: Deleting output directory...
- ==> hyperv-iso: Deleting build directory...
- Build 'hyperv-iso' errored after 8 minutes 51 seconds: Build was cancelled.
-
- ==> Wait completed after 8 minutes 51 seconds
- Cleanly cancelled builds after being interrupted.
-
- F:\packer-hyperv-win2016>packer.exe build WindowsServer.Json
- Warning: Warning when preparing build: "hyperv-iso"
-
- A shutdown_command was not specified. Without a shutdown command, Packer
- will forcibly halt the virtual machine, which may result in data loss.
- hyperv-iso: output will be in this color. ==> hyperv-iso: Creating build directory... ==> hyperv-iso: Retrieving ISO
- ==> hyperv-iso: Trying file://F:\SOFTWARE\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso
- ==> hyperv-iso: Trying file://F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso?checksum=md5%3Ac1f8c8325e88f4687eabc4c60a6c3fcb
- ==> hyperv-iso: file://F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso?checksum=md5%3Ac1f8c8325e88f4687eabc4c60a6c3fcb => F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso ==> hyperv-iso: Creating floppy disk... hyperv-iso: Copying files flatly from floppy_files hyperv-iso: Copying directory: F:\packer-hyperv-win2016/setup/ hyperv-iso: Adding file: F:\packer-hyperv-win2016\setup\Autounattend.xml
- hyperv-iso: Adding file: F:\packer-hyperv-win2016\setup\vmtools.cmd
- hyperv-iso: Done copying files from floppy_files
- hyperv-iso: Collecting paths from floppy_dirs
- hyperv-iso: Resulting paths from floppy_dirs : []
- hyperv-iso: Done copying paths from floppy_dirs
- hyperv-iso: Copying files from floppy_content
- hyperv-iso: Done copying files from floppy_content
- ==> hyperv-iso: Creating switch 'packer-hyperv-iso' if required...
- ==> hyperv-iso: switch 'packer-hyperv-iso' already exists. Will not delete on cleanup...
- ==> hyperv-iso: Creating virtual machine...
- ==> hyperv-iso: Enabling Integration Service...
- ==> hyperv-iso: Mounting os dvd drive F:/SOFTWARE/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso ...
- ==> hyperv-iso: Mounting floppy drive...
- ==> hyperv-iso: Skipping mounting Integration Services Setup Disk...
- ==> hyperv-iso: Mounting secondary DVD images...
- ==> hyperv-iso: Configuring vlan...
- ==> hyperv-iso: Determine Host IP for HyperV machine... ==> hyperv-iso: Host IP for the HyperV machine: 169.254.10.91 ==> hyperv-iso: Attempting to connect with vmconnect... ==> hyperv-iso: Starting the virtual machine... ==> hyperv-iso: Waiting 10s for boot... ==> hyperv-iso: Typing the boot command...
- ==> hyperv-iso: Waiting for WinRM to become available...
- hyperv-iso: WinRM connected. ==> hyperv-iso: Connected to WinRM! ==> hyperv-iso: Provisioning with windows-shell... ==> hyperv-iso: Provisioning with shell script: C:\Users\ADMINI~1\AppData\Local\Temp\windows-shell-provisioner3533260373 hyperv-iso: hyperv-iso: C:\Users\vagrant>dir c:\ hyperv-iso: Volume in drive C is Windows 2016 hyperv-iso: Volume Serial Number is 2657-24CA hyperv-iso:
- hyperv-iso: Directory of c:\
- hyperv-iso:
- hyperv-iso: 2016/09/12 20:45 <DIR> Logs
- hyperv-iso: 2016/07/16 21:23 <DIR> PerfLogs
- hyperv-iso: 2016/09/12 20:45 <DIR> Program Files
- hyperv-iso: 2016/07/16 21:23 <DIR> Program Files (x86)
- hyperv-iso: 2021/12/25 10:59 <DIR> Users
- hyperv-iso: 2021/12/25 10:58 <DIR> Windows
- hyperv-iso: 0 File(s) 0 bytes
- hyperv-iso: 6 Dir(s) 53,121,290,240 bytes free
- ==> hyperv-iso: Forcibly halting virtual machine...
- ==> hyperv-iso: Waiting for vm to be powered down...
- ==> hyperv-iso: Unmount/delete secondary dvd drives...
- ==> hyperv-iso: Unmount/delete Integration Services dvd drive...
- ==> hyperv-iso: Unmount/delete os dvd drive...
- ==> hyperv-iso: Delete os dvd drives controller 0 location 1 ...
- ==> hyperv-iso: Unmount/delete floppy drive (Run)...
- ==> hyperv-iso: Compacting disks...
- hyperv-iso: Compacting disk: packer-hyperv-iso.vhdx
- hyperv-iso: Disk size reduced by: .3%
- ==> hyperv-iso: Exporting virtual machine...
- ==> hyperv-iso: Collating build artifacts...
- ==> hyperv-iso: Disconnecting from vmconnect...
- ==> hyperv-iso: Cleanup floppy drive...
- ==> hyperv-iso: Unregistering and deleting virtual machine...
- ==> hyperv-iso: Deleting build directory...
- Build 'hyperv-iso' finished after 18 minutes 38 seconds.
-
- ==> Wait completed after 18 minutes 38 seconds
-
- ==> Builds finished. The artifacts of successful builds are:
- --> hyperv-iso: VM files in directory: output-hyperv-iso
-
- F:\packer-hyperv-win2016>
Hyper-V 2代硬件中删除了软盘,需要使用光盘提供自动应答文件:
- {
-
- "builders": [
-
- {
- "type": "hyperv-iso",
- "communicator": "winrm",
- "disk_size": 61440,
- "memory": 2048,
- "secondary_iso_images": [
- "./setup/setup.iso"
- ],
- "generation": 2,
- "guest_additions_mode": "disable",
- "headless": false,
- "iso_url": "file://F:\\SOFTWARE\\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_ChnSimp_-2_MLF_X21-22842.iso",
- "iso_checksum": "c1f8c8325e88f4687eabc4c60a6c3fcb",
- "winrm_username": "vagrant",
- "winrm_password": "vagrant",
- "winrm_timeout": "6h"
- }
- ],
- "provisioners": [
- {
- "type": "windows-shell",
- "inline": ["dir c:\\"]
- }
- ]
- }
-
Autounattend.xml
- <?xml version="1.0" encoding="utf-8"?>
- <unattend xmlns="urn:schemas-microsoft-com:unattend">
- <settings pass="windowsPE">
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <SetupUILanguage>
- <UILanguage>en-US</UILanguage>
- </SetupUILanguage>
- <InputLocale>en-US</InputLocale>
- <SystemLocale>en-US</SystemLocale>
- <UILanguage>en-US</UILanguage>
- <UILanguageFallback>en-US</UILanguageFallback>
- <UserLocale>en-US</UserLocale>
- </component>
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <DiskConfiguration>
- <Disk wcm:action="add">
- <CreatePartitions>
- <CreatePartition wcm:action="add">
- <Order>1</Order>
- <Size>500</Size>
- <Type>EFI</Type>
- </CreatePartition>
- <CreatePartition wcm:action="add">
- <Order>2</Order>
- <Size>128</Size>
- <Type>MSR</Type>
- </CreatePartition>
- <CreatePartition wcm:action="add">
- <Order>3</Order>
- <Extend>true</Extend>
- <Type>Primary</Type>
- </CreatePartition>
- </CreatePartitions>
- <DiskID>0</DiskID>
- <WillWipeDisk>true</WillWipeDisk>
- </Disk>
- </DiskConfiguration>
- <ImageInstall>
- <OSImage>
- <InstallFrom>
- <MetaData wcm:action="add">
- <Key>/IMAGE/NAME</Key>
- <Value>Windows Server 2016 SERVERDATACENTER</Value>
- </MetaData>
- </InstallFrom>
- <InstallTo>
- <DiskID>0</DiskID>
- <PartitionID>3</PartitionID>
- </InstallTo>
- </OSImage>
- </ImageInstall>
- <UserData>
- <ProductKey>
- <!-- Do not uncomment the Key element if you are using trial ISOs -->
- <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs -->
- <!-- <Key>6XBNX-4JQGW-QX6QG-74P76-72V67</Key> -->
- <WillShowUI>OnError</WillShowUI>
- </ProductKey>
- <AcceptEula>true</AcceptEula>
- <FullName>Vagrant</FullName>
- <Organization>Vagrant</Organization>
- </UserData>
- </component>
- </settings>
- <settings pass="specialize">
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <OEMInformation>
- <HelpCustomized>false</HelpCustomized>
- </OEMInformation>
- <ComputerName>vagrant-2016</ComputerName>
- <TimeZone>Pacific Standard Time</TimeZone>
- <RegisteredOwner/>
- </component>
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
- </component>
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <IEHardenAdmin>false</IEHardenAdmin>
- <IEHardenUser>false</IEHardenUser>
- </component>
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
- </component>
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <SkipAutoActivation>true</SkipAutoActivation>
- </component>
- </settings>
- <settings pass="oobeSystem">
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <AutoLogon>
- <Password>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </Password>
- <Enabled>true</Enabled>
- <Username>vagrant</Username>
- </AutoLogon>
- <FirstLogonCommands>
- <SynchronousCommand wcm:action="add">
- <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
- <Description>Set Execution Policy 64 Bit</Description>
- <Order>1</Order>
- <RequiresUserInput>true</RequiresUserInput>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
- <Description>Set Execution Policy 32 Bit</Description>
- <Order>2</Order>
- <RequiresUserInput>true</RequiresUserInput>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File e:\disable-winrm.ps1</CommandLine>
- <Description>Disable WinRM</Description>
- <Order>3</Order>
- <RequiresUserInput>true</RequiresUserInput>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
- <Order>4</Order>
- <Description>Show file extensions in Explorer</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine>
- <Order>5</Order>
- <Description>Enable QuickEdit mode</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine>
- <Order>6</Order>
- <Description>Show Run command in Start Menu</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine>
- <Order>7</Order>
- <Description>Show Administrative Tools in Start Menu</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine>
- <Order>8</Order>
- <Description>Zero Hibernation File</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine>
- <Order>9</Order>
- <Description>Disable Hibernation Mode</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
- <Order>10</Order>
- <Description>Disable password expiration for vagrant user</Description>
- </SynchronousCommand>
- <SynchronousCommand wcm:action="add">
- <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File e:\enable-winrm.ps1</CommandLine>
- <Description>Enable WinRM</Description>
- <Order>99</Order>
- </SynchronousCommand>
- </FirstLogonCommands>
- <OOBE>
- <HideEULAPage>true</HideEULAPage>
- <HideLocalAccountScreen>true</HideLocalAccountScreen>
- <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
- <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
- <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
- <NetworkLocation>Home</NetworkLocation>
- <ProtectYourPC>1</ProtectYourPC>
- </OOBE>
- <UserAccounts>
- <AdministratorPassword>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </AdministratorPassword>
- <LocalAccounts>
- <LocalAccount wcm:action="add">
- <Password>
- <Value>vagrant</Value>
- <PlainText>true</PlainText>
- </Password>
- <Group>administrators</Group>
- <DisplayName>Vagrant</DisplayName>
- <Name>vagrant</Name>
- <Description>Vagrant User</Description>
- </LocalAccount>
- </LocalAccounts>
- </UserAccounts>
- <RegisteredOwner/>
- </component>
- </settings>
- <settings pass="offlineServicing">
- <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
- <EnableLUA>false</EnableLUA>
- </component>
- </settings>
- <cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="wim:c:/wim/install.wim#Windows Server 2016 SERVERSTANDARD"/>
- </unattend>
从目录创建iso的PowerShell脚本
- function New-IsoFile
- {
- <# .Synopsis Creates a new .iso file .Description The New-IsoFile cmdlet creates a new .iso file containing content from chosen folders .Example New-IsoFile "c:\tools","c:Downloads\utils" This command creates a .iso file in $env:temp folder (default location) that contains c:\tools and c:\downloads\utils folders. The folders themselves are included at the root of the .iso image. .Example New-IsoFile -FromClipboard -Verbose Before running this command, select and copy (Ctrl-C) files/folders in Explorer first. .Example dir c:\WinPE | New-IsoFile -Path c:\temp\WinPE.iso -BootFile "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\efisys.bin" -Media DVDPLUSR -Title "WinPE" This command creates a bootable .iso file containing the content from c:\WinPE folder, but the folder itself isn't included. Boot file etfsboot.com can be found in Windows ADK. Refer to IMAPI_MEDIA_PHYSICAL_TYPE enumeration for possible media types: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366217(v=vs.85).aspx .Notes NAME: New-IsoFile AUTHOR: Chris Wu LASTEDIT: 03/23/2016 14:46:50 #>
-
- [CmdletBinding(DefaultParameterSetName='Source')]Param(
- [parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true, ParameterSetName='Source')]$Source,
- [parameter(Position=2)][string]$Path = "$env:temp\$((Get-Date).ToString('yyyyMMdd-HHmmss.ffff')).iso",
- [ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})][string]$BootFile = $null,
- [ValidateSet('CDR','CDRW','DVDRAM','DVDPLUSR','DVDPLUSRW','DVDPLUSR_DUALLAYER','DVDDASHR','DVDDASHRW','DVDDASHR_DUALLAYER','DISK','DVDPLUSRW_DUALLAYER','BDR','BDRE')][string] $Media = 'DVDPLUSRW_DUALLAYER',
- [string]$Title = (Get-Date).ToString("yyyyMMdd-HHmmss.ffff"),
- [switch]$Force,
- [parameter(ParameterSetName='Clipboard')][switch]$FromClipboard
- )
-
- Begin {
- ($cp = new-object System.CodeDom.Compiler.CompilerParameters).CompilerOptions = '/unsafe'
- if (!('ISOFile' -as [type])) {
- Add-Type -CompilerParameters $cp -TypeDefinition @'
- public class ISOFile
- {
- public unsafe static void Create(string Path, object Stream, int BlockSize, int TotalBlocks)
- {
- int bytes = 0;
- byte[] buf = new byte[BlockSize];
- var ptr = (System.IntPtr)(&bytes);
- var o = System.IO.File.OpenWrite(Path);
- var i = Stream as System.Runtime.InteropServices.ComTypes.IStream;
-
- if (o != null) {
- while (TotalBlocks-- > 0) {
- i.Read(buf, BlockSize, ptr); o.Write(buf, 0, bytes);
- }
- o.Flush(); o.Close();
- }
- }
- }
- '@
- }
-
- if ($BootFile) {
- if('BDR','BDRE' -contains $Media) { Write-Warning "Bootable image doesn't seem to work with media type $Media" }
- ($Stream = New-Object -ComObject ADODB.Stream -Property @{Type=1}).Open() # adFileTypeBinary
- $Stream.LoadFromFile((Get-Item -LiteralPath $BootFile).Fullname)
- ($Boot = New-Object -ComObject IMAPI2FS.BootOptions).AssignBootImage($Stream)
- }
-
- $MediaType = @('UNKNOWN','CDROM','CDR','CDRW','DVDROM','DVDRAM','DVDPLUSR','DVDPLUSRW','DVDPLUSR_DUALLAYER','DVDDASHR','DVDDASHRW','DVDDASHR_DUALLAYER','DISK','DVDPLUSRW_DUALLAYER','HDDVDROM','HDDVDR','HDDVDRAM','BDROM','BDR','BDRE')
-
- Write-Verbose -Message "Selected media type is $Media with value $($MediaType.IndexOf($Media))"
- ($Image = New-Object -com IMAPI2FS.MsftFileSystemImage -Property @{VolumeName=$Title}).ChooseImageDefaultsForMediaType($MediaType.IndexOf($Media))
-
- if (!($Target = New-Item -Path $Path -ItemType File -Force:$Force -ErrorAction SilentlyContinue)) { Write-Error -Message "Cannot create file $Path. Use -Force parameter to overwrite if the target file already exists."; break }
- }
-
- Process {
- if($FromClipboard) {
- if($PSVersionTable.PSVersion.Major -lt 5) { Write-Error -Message 'The -FromClipboard parameter is only supported on PowerShell v5 or higher'; break }
- $Source = Get-Clipboard -Format FileDropList
- }
-
- foreach($item in $Source) {
- if($item -isnot [System.IO.FileInfo] -and $item -isnot [System.IO.DirectoryInfo]) {
- $item = Get-Item -LiteralPath $item
- }
-
- if($item) {
- Write-Verbose -Message "Adding item to the target image: $($item.FullName)"
- try { $Image.Root.AddTree($item.FullName, $true) } catch { Write-Error -Message ($_.Exception.Message.Trim() + ' Try a different media type.') }
- }
- }
- }
-
- End {
- if ($Boot) { $Image.BootImageOptions=$Boot }
- $Result = $Image.CreateResultImage()
- [ISOFile]::Create($Target.FullName,$Result.ImageStream,$Result.BlockSize,$Result.TotalBlocks)
- Write-Verbose -Message "Target image ($($Target.FullName)) has been created"
- $Target
- }
- }
-
- $source_dir = "setup"
- get-childitem "$source_dir" | New-ISOFile -path setup.iso
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。