Windows Server 2022 & Powershell All-in-One For Dummies. Sara Perrott

Читать онлайн книгу.

Windows Server 2022 & Powershell All-in-One For Dummies - Sara Perrott


Скачать книгу
want it to work and don't need to customize it. The command starts the WinRM service if it isn’t already started, and ensures that WinRM is set to automatically start. It also configures listeners for HTTP and HTTPS, and ensures that the Windows firewall is allowing HTTP and HTTPS traffic inbound.

      The Enable-PSRemoting command will not give you any output if it succeeds. You’ll simply be presented with the PowerShell prompt again.

       Enable-PSRemoting -force

      Running winrm quickconfig is a little different. After it runs its analysis, it tells you what needs to be changed and asks for a yes or no as to whether it can make the necessary changes. Select Y and press Enter. If everything looked good during the analysis, you'll be told that WinRM is already running and is already set up for Remote Management instead of the yes/no question.

       winrm quickconfig

      Configure Windows Firewall

       Get-NetFirewallRule *remote* | Format-table

Snapshot of using Get-NetFirewallRule to find rules.

      FIGURE 4-11: Using Get-NetFirewallRule to find rules.

      The preceding command looks for any rules that have remote in the name. You can see each rule and whether it's enabled.

      Let’s enable the Remote Firewall Management rules. These would allow you to administer this server’s firewall from another system. The rules you’re interested in are RemoteFwAdmin-In-TCP and RemoteFWAdmin-RPCSS-In-TCP.

       Set-NetFirewallRule –Name "RemoteFwAdmin-In-TCP" –Enabled TrueSet-NetFirewallRule –Name "RemoteFwAdmin-RPCSS-In-TCP" –Enabled True

      If the commands complete successfully, you’ll get no response. You’ll be returned to the PowerShell prompt. If you run your search again, you’ll see that these rules are now enabled.

Snapshot of using PowerShell to set firewall rules and validate that they�re enabled.

      FIGURE 4-12: Using PowerShell to set firewall rules and validate that they’re enabled.

      With Windows Server 2008, Microsoft introduced a utility called BCDEdit, which allows you to manipulate the Windows boot configuration data (BCD) store. The BCD is used to tell the operating system how it should boot; it contains all the boot configuration parameters needed to support that function. This replaced the older bootcfg.exe utility that was used to edit the boot.ini file pre–Windows Vista. You must be a member of the local Administrator's group on a system to use BCDEdit. This is an advanced utility that is useful in troubleshooting issues that are preventing a server from booting properly.

      

You may need to disable or suspend both BitLocker and Secure Boot on a system before you can use BCDEdit.

      

Mistakes made using the BCDEdit utility could leave your system unable to boot at all. Always make sure that you either have a good backup of the system, or if you don’t have a good backup, export the current settings from BCDEdit so that you can restore them if needed. You can export the current boot configuration database by typing BCDEdit /Export <export_path>. If you need to restore from that export, the command is very similar. You need only type BCDEdit /Import <path_to_export>.

Option Description
/bootdebug Enables or disables boot debugging.
/dbgsettings Configures the type of debugging connection.
/debug Enables or disables kernel debugging.
/delete Deletes boot entries from the datastore — use with caution!
/deletevalue Deletes or removes a boot entry option — use with caution!
/displayorder Sets the order used by the boot manager when displaying the multiboot menu.
/enum Lists all the entries in the boot configuration datastore.
/export Exports the contents of the BCD; can be used as a backup to restore the BCD.
/import Imports the contents of an exported file; can be used as a restore option if needed.
/set Sets a value in a boot option.

      You may notice that the description in the Windows Boot Loader just says Windows Server. Maybe you want it to be more descriptive than that. You can change it with bcdedit /set. You need the ID of the object that you're wanting to work on. In this case, you’re wanting to edit the Windows Boot Loader; the identifier that you can see in Figure 4-13 is {current}. The full command you type will look something like this:

       bcdedit /set {current} description "Windows Server 2022 Standard"

      

This command will work perfectly in a command prompt, but if you try to run it in PowerShell, you’ll need to put quotes around the identifier. For instance, if I were
Скачать книгу