Install-Module VMWare.PowerCLI -Scope CurrentUser
The following code invokes script on machine to configure WinRM service for powershell remoting. This allows execution of various Windows Server operations remotely.
Connect-VIServer '<ip address vmx console>'
$LocalIPAddress = '<IP address of client machine>'
$GuestCredential = Get-Credential
$VMNames = '<name of VM on VMWare>','<name of VM on VMWare';
foreach ($VMName in $VMNames)
{
$VM = Get-VM -name $VMName;
Invoke-VMScript -vm $VM -GuestCredential $GuestCredential -ScriptText "Enable-PSRemoting -Force;Set-Item WSMan:\localhost\Client\TrustedHosts -Concatenate -Value '$LocalIPAddress' -Force;Get-Item WSMan:\localhost\Client\TrustedHosts;winrm quickconfig -quiet;Restart-Service WinRM;" -ScriptType PowerShell
Start-Process powershell -Verb runAs -ArgumentList "& '-Item -Concatenate -Value $VM.Guest.IPAddress'"
Enter-PSSession -ComputerName "$($VM.Guest.IPAddress)" -Credential $GuestCredential
}
$VM = Get-VM -name "Test Windows Server 4"; Invoke-VMScript -vm $VM -GuestCredential $GuestCredential -ScriptType PowerShell -ScriptText 'Set-LocalUser -Name "Administrator" -AccountNeverExpires:$true -PasswordNeverExpires:$true'
$VMNames = '<name of VM on VMWare>','<name of VM on VMWare';
$SnapshotName = 'Base Install';
foreach ($VMName in $VMNames)
{
$VM = Get-VM -name $VMName;
$shutdownStatus = Shutdown-VMGuest -VM $VM -Confirm:$false;
Do { Start-Sleep -Seconds 5; $currentVMState =Get-VM $vmName; $status = $currentVMState.PowerState } Until ( $status -eq "PoweredOff");
$Snap = Get-Snapshot -VM $VM -Name "$SnapshotName";
$revertStatus = Set-VM -VM $VM -Snapshot $Snap -Confirm:$false;
$startStatus = Start-VM -VM $VM
}
-
Disable Serial, Parallel Ports and Floppy controller in Bios
-
Install/Update VMWare Tools
-
License
-
Set Administrator Password
-
Date/Time Zone
-
Patch
-
Turn off system restore
-
Enable Remote access
-
System Settings -> Performance Best performance. 10 Startup and recovery-> Display list for 5 seconds
-
Power options-> Balanced -> Never
-
Personalization -> Turn off sound
-
Screen saver -> None
-
Taskbar -> Start Menu -> Power button -> Logoff
-
Enable Telent Client and disable other items in features : Media features, Print and Document Services, tablet pc components, XPS Services
-
Internet Explorer : About:blank
-
Disable Windows service : Windows Search; change registry in windows 10 to disable cloud search: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search] "BingSearchEnabled"=dword:00000000 "AllowSearchToUseLocation"=dword:00000000 "CortanaConsent"=dword:00000000 https://www.neowin.net/news/the-windows-10-spring-update-no-longer-lets-you-disable-web-search-in-start
-
System icon Volume, Action Center turn off
-
Always show all icons & notification in task bar
-
Depends on OS: Start menu -> Number of recent programs : 0 , in jump list: 0 , help uncheck. highlight newly installed program uncheck, use large icon: uncheck, documents,music, Pictures, personal folders, don't display; display run ; System admin tools: All prog & start menu; uncheck store & display recently opened programs & items.
-
taskbar buttons: Combine when taskbar is full.
-
Folder & Search options: always show icons never thumbnails, always show menus, fulll path, show hidden files, uncheck hide, >apply to all folders
-
Control panel - small icons
-
Control Panel > Sync Center > Manage offline files->General (Tab) > Disable offline files
-
Install/Update a. Notepad++ b. Chrome/Edge c. bginfo --> Copy shortcut with following command to bginfo /timer:0 d. Uninstall onedrive
-
Copy the default profile by rebooting in safemode, login as third user, renaming "Default" folder and copying users directory to Default folder delete third user after setup.
-
Enable Administrator user id if disabled.
-
Needed if using old image: Fix Rearm issue on previous files: https://www.wintips.org/fix-sysprep-fatal-error-dwret-31-machine-invalid-state-couldnt-update-recorded-state/ a. HKEY_LOCAL_MACHINE\System\Setup\Status\Sysprep Status - CleanupState 2, GeneralizationState 7 b. HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\SoftwareProtectionPlatform --> SkipRearm 1 c. admin cmd --> msdtc -uninstall; reboot; msdtc -install; reboot
-
Delete C:\Windows\System32\Sysprep\Panther 30 Cleanup C:\Windows\Temp\vmware-* (some files may fail); C:\Windows\Temp\vmware-imc*
-
Disable Hibernation(run cmd as administrator) powercfg.exe –h off bcdedit /timeout 5
-
cleanmgr.exe, cleanmgr /sageset:1
-
wevtutil el | Foreach-Object {wevtutil cl "$_"}
-
Control Panel->System->Advanced System Properties->performance->Advance->Virtual Memory->Change Uncheck “Automatically manage paging file size for all drives” Select “No paging file” Click “Set” to disable swap file
-
dfrgui.exe (only available on windows 7 and Thick provisioned drives)
-
Ensure that VM file size is packed a. Run sdelete -z C: on windows b. run cat /dev/zero > /big_zero ; sync; rm /big_zero c. shutdown the machine d. login to ESX server and run the command to thin and reduce size of the file. vmkfstools -K .vmdk
-
Start machine Enable paging files and shutdown
-
Change Disk to client and change network to generic location
-
Create template