Windows Server 2022 & Powershell All-in-One For Dummies. Sara Perrott
Читать онлайн книгу.force Server Core to then detect and install any available updates, simply type the following command and press Enter.
wuauclt /detectnow
Customizing Windows Server 2022
After your Windows Server operating system is installed, the next step is to customize it and make it your own! This involves things like installing roles and features, setting up remote administration, and configuring the firewall.
Windows Server 2022 with Desktop Experience
I'll start the customization discussion with the Desktop Experience. When you log into a server with Desktop Experience enabled, by default Server Manager will launch. A lot of the configuration and customization tasks you may have can be accomplished from Server Manager.
Adding roles and features
Roles and features are added in Windows Server 2022 with Desktop Experience through Server Manager.
1 Open Server Manager.
2 Choose Manage⇒ Add Roles and Features.
3 On the Before You Begin page, click Next.
4 On the Select Installation Type page, click Next.
5 On the Select Destination Server page, click Next.
6 Check the check box next to the role that you want to install and click Next.For this demonstration, I’ve chosen File Server under File and Storage Services (see Figure 4-8).FIGURE 4-8: The select Server Roles Screen with File Server selected.
7 On the next screen, select any features you may want to install and then click Next.
8 If you want the server to restart automatically if needed for the role you installed, you can select the Restart the Destination Server Automatically if Required check box. If a restart is not needed, or you don’t want it to restart, leave the check box unchecked.
9 Click Install to install the roles and/or features you selected.
Enabling remote administration
Remote Management is enabled by default and allows for remote administration through PowerShell. Remote Desktop is a separate setting that allows you to connect to the server and work with it directly.
When a server has Desktop Experience, administrators often prefer to work with the server over Remote Desktop. This is disabled by default; you enable it to use it. If the firewall on the server is enabled and does not have Remote Desktop enabled, you won’t be able to connect to it. You need to enable the Remote Desktop – User Mode (TCP-In) rule listed in the Inbound Rules of your server’s firewall.
1 With Server Manager open, click Local Server in the left-hand menu.
2 Click the hyperlink next to Remote Desktop that says Disabled.
3 In the dialog box that appears, select Allow Remote Connections to This Computer.A dialog box appears telling you that a firewall exception will be made for Remote Desktop.
4 Click OK.
5 If you want to set remote access for specific people or groups, click the Select Users button.
6 Click Add, choose your person or group, and click OK.
7 Click OK again on Remote Desktop Users to close out of it.
8 Click OK one more time on the System Properties screen to enable Remote Desktop.
Configure Windows Firewall
Assuming that you’re going to use the Windows Firewall on your server, you need to know how to enable applications through the firewall. By allowing inbound traffic, you enable the server to do the job you plan on using it for.
1 From Server Manager, select Local Server on the left-hand side.
2 Click the Private: On link next to Microsoft Defender Firewall.The Firewall & Network Protection app opens.
3 Click Allow an App through Firewall.
4 Select File and Print Sharing and enable it for the Private profile by selecting the check box under Private (see Figure 4-9).
5 Click OK to save your changes.
FIGURE 4-9: Allowing an app through Microsoft Defender Firewall.
Windows Server 2022 Core
Whether you’re running PowerShell commands against your Windows Server Core system while connected to the console or through remote PowerShell, you can do much of your configuration work with just a few PowerShell commands.
Adding roles and features
To get really good working with Server Core, half of the battle you face is learning how to find the things you want. In Server with Desktop Experience, you have the GUI to guide you. Not so with Server Core.
Let’s look at the example I used with the Desktop Experience server. You want to install the File Server role. Before you can install the role, you need to find out what to call it. By using Get-WindowsFeature
, you can find the names of the roles and features you’re interested in. If you have an idea of what the name is, you can do a wildcard search. In the following example, I’ve used *file*
to indicate that I want the Get-WindowsFeature
cmdlet to return results that have the word file in them.
Get-WindowsFeature *file*
When you type the preceding command, you get three results of items that have file in their names. You can see File Server under Display Name. For the installation command, you need the name under the Name column. In this case, it's FS-FileServer. Now you’re ready to install it! Use the following command to install the File Server (see Figure 4-10):
Install-WindowsFeature FS-FileServer
FIGURE 4-10: Using PowerShell to install roles and features.
You see a progress bar as the feature is installed. After it’s installed, if you run the first command again, you see that all three results are now installed. File and iSCSI Services was installed because File Server relies on it.
Enabling remote administration
Remote Management is enabled by default in Windows Server 2022. If it was disabled in your environment, you can enable it by running the Configure-SMRemoting
command. This allows you remotely administer your server with Server Manager.
Configure-SMRemoting -Enable
To be able to administer the server remotely with PowerShell, you need two additional commands. Enable-PSRemoting
configures PowerShell to receive remote commands that are sent to your system. Winrm quickconfig
will analyze and automatically configure the WinRM service