Windows Administration Notes and Commands

Date Published: January 31, 2022

This article provides useful notes and PowerShell commands for managing Windows systems. It covers boot repairs, managing services, enabling features like Remote Desktop, and various configuration tasks for efficient system administration.


Fixing Boot Issues

When dealing with a Windows system that won’t boot, follow these steps:

  1. Format the System Partition:
    • Use your preferred tool to format the system partition.
  2. Repair Boot Files:

Note:

If the repair doesn’t work, try formatting the system partition and writing the boot files to the OS drive instead.


Managing the Company Portal Cache

If cached data causes issues in the Company Portal, clear the following folder:

%localappdata%\Packages\Microsoft.CompanyPortal_8wekyb3d8bbwe\TempState\ApplicationCache

Check Windows Services

Use the following PowerShell command to find services set to start automatically but are not running:

get-service | where-object {$_.StartType -eq "Automatic" -and $_.Status -ne "Running"}

Enable Remote Desktop

Enable Remote Desktop on a system using these commands:

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

Splitting a WIM File

When creating installation media, split a WIM file to ensure compatibility with FAT32:

dism /Split-Image /ImageFile:”install.wim” /SWMFile:”install.swm” /FileSize:4000

Refer to Dell’s guide on WIM file compatibility.


Windows Installer RDS Compatibility Mode

When installing software in a Remote Desktop Services (RDS) environment:

  • Before installation: Set the registry key using PowerShell:
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\TSAppSrv' -Name "TSMSI" -Value 0
    
  • After installation: Reset the key using PowerShell:
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\TSAppSrv' -Name "TSMSI" -Value 1
    

More details can be found on ADMX Help.


Rebooting a Remote Machine on a Different Domain

Use the following commands to reboot a remote machine:

NET USE \\computername\IPC$ dolphin /USER:username
shutdown /r /t 30 /m \\computername

Accessing Remote MMC

Open the Microsoft Management Console (MMC) for a machine on a different domain:

runas /noprofile /netonly /user:192.168.1.1\username "mmc compmgmt.msc"

Add Azure AD User to Local Group

To add an Azure AD user to a local group:

net localgroup "Hyper-V Administrators" AzureAD\firstname.surname@contoso.com /add

Create OS Installation Media

  1. Open DiskPart and prepare the USB drive:
    diskpart
    list disk
    select disk X (replace X with the USB drive number)
    clean
    convert GPT
    create partition primary size=32000
    format fs=FAT32 quick label=Boot
    assign
    exit
    
  2. Mount the Windows ISO and copy files:
    bootsect /nt60 D:
    

    Use Windows Explorer to copy the ISO files to the boot partition on the USB drive.