Windows Server – Sysprep

KB ID 0000729 

Problem

I don’t deploy large amounts of servers at once, so Windows Server sysprep is not as important as it is with the client operating systems I deploy. But I do need to create virtual machine templates, (mostly for testing), but some clients like to have server templates. I prefer to manually sysprep and shutdown a server then either convert or clone it to a template.

Thankfully sysprep is in the same place as it was with Server 2008 R2.

Solution

As before you can either run sysprep from command line by navigating to its location and running it with the correct switches. Or simply browse to it with Windows Explorer and double click it.

Related Articles, References, Credits, or External Links

Server 2008 R2 Where is Sysprep

TinyCore Linux: Build a ‘Persistent’ Web Server

KB ID 0001697

Problem

Recently I was building a lab for testing load balancing, and needed some web servers, I could have built three Windows servers, but I wanted to run them in EVE-NG, so they had to be as light as I could make them. I chose TinyCore Linux, (I know there are smaller options, but it’s light enough for me to run, and work with).

The problem occurs when you reboot the TinyCore host, it (by default) reverts back to its vanilla state, (that’s not strictly true, a couple of folders are persistent).

So I had to build a server that would let me SFTP some web content into it and allow me to reboot it without losing the web content, settings, and IP address.

Step 1: Configure TinyCore IP & Web Server

This is a two step procedure, firstly I’m going to give it a static IP.

[box]

sudo ifconfig eth0 192.168.100.110 netmask 255.255.255.0
sudo route add default gw 192.168.100.1

[/box]

I don’t need DNS, if you do, then simply edit the resolve.conf file;

[box]

sudo vi /etc/resolv.conf
Add a value e.g.
Nameserver 8.8.8.8

[/box]

If you are scared of  the VI editor see Using the VI Editor (For Windows Types)

To connect via SSH/SFTP you will need opnessh installing, and to run the website, we will use Busybox, to install those, do the following;

[box]

tce-load -wi busybox-httpd.tcz
tce-load -wi openssh

[/box]

You will now need to set a password for the root account, (so you can log on and trasfer web files in!)

[box]

su
passwd
Type in, and confirm a new password!

[/box]

Start the OpenSSH, and TFTP services;

[box]

cd /usr/local/etc/init.d/
./openssh start
cd /etc/init.d/services/
./tftpd start

[/box]

Now create a basic web page, (index.html) which you can update later. Setup the website, then copy that file to a location that will be persistent (you will see why later).

[box]

cd /usr/local/httpd/bin
sudo ./busybox httpd -p 80 -h /usr/local/httpd/bin/
sudo vi index.html {ENTER SOME TEXT TO TEST, AND SAVE}
sudo mkdir /mnt/sda1/wwwsite/
sudo cp /usr/local/httpd/bin/index.html /mnt/sda1/wwwsite/index.html

[/box]

At this point, (if you want) you can use your favourite SFTP client, (I recommend FileZilla or WinSCP) and copy in some live web content to /mnt/sda1/wwwsite/ But ensure the home/landing page is still index.html though!

Step 2: Make TinyCore Settings ‘Persistent’

There may be better ways to do this, this just worked for me, and made sense! There’s a shell script that is executed as the TinyCore machine boots (bootlocal.sh) so if you edit that file and put in the commands to configure the IP, copy the website files from the permanent mount folder, start the web server, then start SSH and TFTP, you end up with a server doing what you want, every time the server boots.

[box]

sudo vi /opt/bootlocal.sh

ADD THE FOLLOWING TO THE BOTTOM OF THE FILE;

sudo ifconfig eth0 192.168.100.110 netmask 255.255.255.0 
sudo route add default gw 192.168.100.1
cp /mnt/sda1/wwwsite/index.html /usr/local/httpd/bin/index.html
cd /usr/local/httpd/bin/
Sudo ./busybox httpd -p 80 -h /usr/local/httpd/bin/
cd /usr/local/etc/init.d/
./openssh start
cd /etc/init.d/services/
./tftpd start

[/box]

Save and exit the file, then finally BACKUP THE CHANGES with the following command;

[box]

filetool.sh -b

[/box]

Related Articles, References, Credits, or External Links

NA

Windows Server – Schedule a Reboot

KB ID 0001321 

Problem

Back in the day we just used the ‘At’ command to schedule a reboot, but starting with Server 2012 that was stopped! If you try it now you will see the following;

The AT command has been depreciated. Please use schtasks.exe instead

Solution (The Quick Way)

Execute the following command (change time and data accordingly);

[box]

schtasks /create /tn “Scheduled Reboot” /tr “shutdown /r /t 0” /sc once /st 12:20:00 /sd 02/03/2020 /ru “System”
[/box]

Solution (The Long Way)

Launch Task Scheduler.

Create Basic Task.

Give the task a name, (and optionally a description) > Next > One time > Next > Enter the date and time for the reboot to occur > Next.

Start a program > Next > Program/Script = PowerShell > Add Arguments = Restart-Computer -Force > Next > Finish.

Related Articles, References, Credits, or External Links

NA

VMware vSphere Hot Add and Hot Plug

KB ID 0000527 

Problem

I was trying to hot add some memory to a VM the other day, and found the option grayed out. Normally I’d just down the VM, add the memory, then bring it back up. But it was a production server and I was pretty sure the OS supported it.

A quick Google search told me why it was grayed out, but it also transpired there was little to no information on what version of Windows hot add and hot plug would work with.

Solution

I’m not going to argue the semantics of the differences between “hot add” and “hot plug”, if I’m taking about hot add I’m talking about memory, if I’m talking about hot plug I’m talking about adding CPUs. You also need to be aware that to date Few OS’s support hot remove or hot unplug. If you try you will see the following;

vSphere version 6 or 6.5 (Hot Unplug )

It simply wont let you lower the value;

Note: With a Supported O,S (i.e. Server 2016 and 2019) you CAN hot remove CPU.

vSphere version 5.0 or 5.5

Hot Add Memory/ CPU in vSphere 6 & 6.5

As with earlier version of vSphere, to enable hot plug or hot remove, the machine has to be shut down. Then the option can be enabled. Select the VM > Edit Settings.

Memory: Virtual Hardware > Memory > Tick ‘Memory Hot Plug’ > Save.

CPU: Virtual Hardware > CPU > Tick ‘Enable CPU Hot Add’ > Save.

Hot Plug, Hot Add  in the vSphere HTML5 Client

Hot Add Memory/ CPU in vSphere 5 & 5.5

As for memory and CPU settings you will probably see what I was seeing. Both the options are not changeable.

2. Sorry but to enable this feature you need to power off the client machine, then when you edit its settings > Options > Advanced > Memory/CPU_Hotplug > You can enable hot add and hot plug > OK . Power the VM back on again.

3. Now you will see you have the option to hot add memory and hot plug CPUs.

What Operating Systems support this?

Like I said above, I did some testing because information is thin on the ground, this is what I was actually able to make work.

With 2008 R2 Standard

1. As you can tell from the table memory hot add will work but to add a CPU will need a reboot. Before I started I had 2 CPUs and 4GB of memory.

2. Lets add more memory and CPUs.

3. For all machines I tested there was a lag, sometimes as little as 3-5 seconds, other times as long as 15-20 seconds, during this time you will see some processor and memory usage spikes. But as shown the memory eventually becomes available.

4. Post reboot, your extra CPUs will appear.

With 2008 R2 Enterprise and Datacenter

1. Note I’m using Datacenter here, but Enterprise is the same. I increased the memory from 4 to 5 GB, And added a further 3 CPUs.

2. It does work, you simply need to restart the “Task Manager” to reflect the increased CPU count.

3. Finished.

Related Articles, References, Credits, or External Links

NA

PowerShell: Restart Fails ‘Other Users Logged On’

KB ID 0001374

Problem

If you intend to shutdown, or restart a remote computer using PowerShell, you may see the following error message;

PS C:\> Restart-Computer “Computer-name
Restart-Computer : This command cannot be run on target computer(‘Computer-name’) due to following error: The system shutdown cannot be initiated because there are other users logged on to the computer.
At line:1 char:1
+ REstart-Computer “Computer-name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Computer-name:String) [Restart-Computer], InvalidOperationException
+ FullyQualifiedErrorId : RestartComputerFailed, Microsoft.PowerShell.Commands.RestartComputerCommand

Solution

You need to add the -Force flag to the command like so;

Related Articles, References, Credits, or External Links

NA

vSphere Error – ‘The operation is not allowed in the current connection state of the host’

KB ID 0000848 

Problem

You can see this either when attempting to power on a VM, or when attempting to deploy a VM from a template.

Solution

Thankfully it’s a really easy fix.

1. Connect to the console of your Virtual Center, (either through the VI client or via RDP)

2. Windows Key+R > Services.msc {Enter} > Locate the VMware Virtual Center Server service > Restart it.

Note: If you have the vCenter appliance, simply reboot it.

Related Articles, References, Credits, or External Links

NA

Windows – System Hung applying updates ‘Stage 3 of 3 Preparing to configure Windows…’

KB ID 0000640

Problem

I installed a classroom full of PC’s today, after setting them all updating, and rebooting, I went to lunch, and came back to find them all displaying this,

Stage 3 of 3
Preparing to configure Windows.
Don't turn off your computer.

I went and did another room, came back, and there was no change.

Solution

It turns out this is a known problem if you are installing KB2533552, to get round the problem simply press CTRL+ALT+DELETE, and you will be presented with the login page.

Microsoft recommend you install the above update separately.

Note: It will affect both Windows 7 and Server 2008 R2.

Related Articles, References, Credits, or External Links

NA

Windows – Schedule a Reboot For a Specific Time

KB ID 0000866 

Problem

If you want to do this, and you do a quick internet search, all results come back as either suggesting using psshutdown or writing a script then scheduling that. I suppose a script is a good idea if you want to reboot at 01:00 every day for example. But what if you want to reboot a client server once at 17:00 and it’s 10:00 in the morning? Chances are, if you’re like me, you will be working on something different at 17:00 and forget!

Solution

1. Painfully simple, open a command window (Windows Key+R > cmd {Enter}).

2. Execute the command below. Obviously change the time accordingly;

[box]

at 10:15:00 shutdown /r /f

[/box]

3. Then the machine will reboot at the specified time.

Related Articles, References, Credits, or External Links

NA

WDS Deploying Windows Part 2: Prepare Windows, and Capture to WDS

KB ID 0000737

Problem

In part one we built and configured the WDS Server. Now you need to prepare the reference Windows 8 machine so that you can ‘capture’ its image.

Solution

Before you start, make sure that the machine you are imaging has PLENTY of room on one of its local drive(s), because it copies the image locally, before it sends it to WDS.

Place Your Reference Windows 8 Machine in Audit Mode

To put all the software on your reference machine and configure it how you like, the machine needs to be in ‘Audit Mode’ before you start. There are TWO ways to put the machine into audit mode.

Note: While a machine is in audit mode, it will log on automatically as the Administrator, and every time the machine boots sysprep will launch (in anticipation of you needing it).

Option 1: A Newly Built Machine

1. When you have first built the Windows 8 machine, you will see the screen below, Press CTRL+SHIFT+F3, the machine will automatically reboot and enter audit mode.

Option 2: You Are Already in Windows

2. You can also put a Windows 8 machine into audit mode by running the sysprep executable with the /audit switch.

3. Once in Audit mode, install all the program and configure all the settings you want in your master image. When you are happy run the sysprep program, (Or simply reboot, as sysprep launches at every boot when you are in audit mode).

4. Tick the ‘Generalize’ option, select either shutdown or reboot, (If you choose reboot make sure the machine is ready to pXe boot from the network, and the boot order has the NIC BEFORE the hard drive, or sysprep will start and rebuild the machine before it’s imaged).

5. Sysprep will run, and shutdown or reboot as requested.

6. When the machine boots press F12 to boot from the WDS server.

7. Note: Now you can see why (in part one) we called the boot image ‘Capture an Image’ and the capture ‘Capture an Image’. Select the capture option.

8. WindowsPE will run at the welcome screen > Next,

Note: If the process fails at this point, usually it’s because the network card driver for this machine IS NOT in the boot image.

Adding Drivers to Images on Windows Deployment Services

9. Select the volume that you want to image, (Note: It will NOT be C: that’s reserved, usually it’s D:) > Give the image a name, this is the name you will see in the WDS console, and when you are imaging the target machines > Enter a comment/description > Next.

10. Browse.

11. Navigate to a local drive, and give the image a name with a .wim extension > Save.

12. Tick the box to upload the image > Supply IP/Name of the WDS server > Connect.

13. Supply credentials to log onto the WDS server > OK.

14. Once authenticated you can select the image group we setup in part one > Next.

15. The image will be created on the reference machine.

16. Then it will be uploaded to the WDS Server.

17. When complete click Finish. At this point the reference machine will reboot and rebuild itself.

18. Back in the Windows Deployment Services management console yo will see the image you have just uploaded in your image group.

Note: Sometimes it can take a while to appear, be patient!

Related Articles, References, Credits, or External Links

2012 – WDS Deploying Windows 8 Part 3: Carry Out a Windows 8 Unattended Deployment 2012 – WDS Deploying Windows 8 Part 1: Install and Configure WDS

 

Stop Windows Rebooting Due To Updates

KB ID 0000773

Problem

I realise that updates are important, and Microsoft made updating easier by only releasing them once a month. But my laptop always wants to reboot at the point where I’m doing something critical! and Windows 8 unilaterally decides that its updates are far more important than my work.

OK this will only happen once a month, (normally) and it will only happen a maximum of 72 hours after the update. It affects me because I never shut my machine down, (I just close the lid).

Warning: Like I said updates are a good thing, if you disable this feature the onus is on you to keep your machine up to date!

Solution

Stop Windows 8 Rebooting Due To Updates with Group Policy

1. Press Windows Key+R > In the run box type gpedit.msc {Enter}.

2. Navigate to;

[box] Computer Configuration > Administrative Templates > Windows Components > Windows Update [/box]

3. Locate the ‘No auto-restart with logged on users for scheduled automatic updates installations’ policy. Set its value to enabled > Apply > OK.

4. Press Windows Key+R > In the run box type cmd {Enter} > At command line issue the following command;

[box] gpupdate /force [/box]

Stop Windows 8 Rebooting Due To Updates via the Registry

Note: If you have already set this in policy (above) you don’t need to do this as well.

5. Press Windows Key+R > In the run box type regedit {Enter} > Navigate to;

[box]HKEY_LOCAL_MACHINE > SOFTWARE > Policies > Microsoft > Windows[/box]

If there is not a Key Called WindowsUpdate create one.

6. And within the WindowsUpdate Key create another key.

7. Call that key AU.

8. Within that create a new DWORD (32 bit) value called ‘NoAutoRebootWithLoggedOnUsers’.

9. Set its value to 1 (one).

 

Related Articles, References, Credits, or External Links

NA