How to Configure Windows Server 2025 with PowerShell
PowerShell is the definitive management interface for Windows Server 2025. While Server Manager and the Windows Admin Center provide graphical options, every action they perform ultimately calls PowerShell cmdlets under the hood. Learning to work directly in PowerShell gives you reproducible, scriptable, and auditable control over every aspect of server configuration. Windows Server 2025 ships with Windows PowerShell 5.1 built in, and PowerShell 7 (the cross-platform successor) can be installed alongside it without conflict. This guide covers everything you need to set up a productive PowerShell environment on a fresh Windows Server 2025 installation — from execution policy and version management through to modules, persistent profiles, command history, and the essential server management cmdlets you will use every day.
Prerequisites
- Windows Server 2025 installed with Desktop Experience or Server Core
- Local administrator or domain administrator account
- Internet connectivity for module and package downloads (or an internal package mirror)
- An elevated PowerShell session (right-click → Run as Administrator)
Step 1 — Understand the Two PowerShell Versions on Server 2025
Windows Server 2025 includes two PowerShell engines that coexist independently. Understanding the difference before you begin is important because modules, profiles, and execution policies are separate between them.
- Windows PowerShell 5.1 — Built into Windows, located at
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe. Uses the.NET Framework. Required by many legacy modules and Windows-specific cmdlets (Get-WindowsFeature,Dism, etc.). - PowerShell 7.x — Installed separately, located at
C:Program FilesPowerShell7pwsh.exe. Uses.NET 8+. Recommended for new scripts and cross-platform work. Supports parallel pipelines, improved error handling, andForEach-Object -Parallel.
# Check the current version of the shell you are in
$PSVersionTable
# Example output for Windows PowerShell 5.1:
# PSVersion 5.1.26100.xxxx
# PSEdition Desktop
# Example output for PowerShell 7:
# PSVersion 7.4.x
# PSEdition Core
Step 2 — Install PowerShell 7 Alongside Windows PowerShell 5.1
PowerShell 7 is installed as a completely separate application and does not replace Windows PowerShell 5.1. Both can run simultaneously.
# Method 1: Install via winget (available on Windows Server 2025)
winget install --id Microsoft.PowerShell --source winget --accept-package-agreements
# Method 2: Install via direct MSI download with PowerShell
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/PowerShell/PowerShell/releases/latest"
$msiUrl = ($latestRelease.assets | Where-Object { $_.name -match "win-x64.msi$" }).browser_download_url
$msiPath = "$env:TEMPPowerShell7.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath
Start-Process msiexec.exe -ArgumentList "/i `"$msiPath`" /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1" -Wait
# Verify installation
& "C:Program FilesPowerShell7pwsh.exe" -Command '$PSVersionTable'
Step 3 — Configure the Execution Policy
By default, Windows Server 2025 has the execution policy set to Restricted, which prevents all scripts from running. Change this to RemoteSigned as a secure baseline — this allows locally created scripts to run but requires downloaded scripts to carry a digital signature.
# Check the current policy at all scopes
Get-ExecutionPolicy -List
# Set RemoteSigned for the local machine (applies to all users)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
# For a stricter environment, use AllSigned
# Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope LocalMachine -Force
# For an individual user session only (does not require admin)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
# Verify
Get-ExecutionPolicy -Scope LocalMachine
Step 4 — Choose Your Editor: Windows PowerShell ISE vs Visual Studio Code
Windows PowerShell ISE (Integrated Scripting Environment) is included with Windows Server 2025 but is no longer actively developed by Microsoft. It only supports Windows PowerShell 5.1 and lacks modern features such as IntelliSense extensions and Git integration. Visual Studio Code with the PowerShell extension is the recommended editor for all new PowerShell development.
# Install Visual Studio Code via winget
winget install --id Microsoft.VisualStudioCode --source winget --accept-package-agreements
# Install VS Code PowerShell extension from the command line after VS Code is installed
& "C:Program FilesMicrosoft VS Codebincode.cmd" --install-extension ms-vscode.powershell
# Open the ISE if you prefer the built-in option (Windows PowerShell 5.1 only)
powershell_ise.exe
# Open a PowerShell file directly in VS Code
code C:ScriptsMyScript.ps1
Step 5 — Install and Manage PowerShell Modules
Modules extend PowerShell with additional cmdlets for specific technologies. The PowerShell Gallery (powershellgallery.com) is the official public repository. Windows Server 2025 also includes built-in modules for managing server roles.
# Trust the PSGallery repository to avoid confirmation prompts
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
# List all currently installed modules
Get-Module -ListAvailable | Select-Object Name, Version, ModuleType | Sort-Object Name
# List modules that are imported into the current session
Get-Module
# Install a module from PSGallery
Install-Module -Name Az -AllowClobber -Scope AllUsers -Force # Azure management
Install-Module -Name PSWindowsUpdate -Scope AllUsers -Force # Windows Update
Install-Module -Name Carbon -Scope AllUsers -Force # Windows config
Install-Module -Name ImportExcel -Scope AllUsers -Force # Excel without Office
# Import a module into the current session
Import-Module -Name PSWindowsUpdate
# Update all installed modules
Get-InstalledModule | Update-Module -Force
# Remove a module from the current session
Remove-Module -Name PSWindowsUpdate
# Uninstall a module completely
Uninstall-Module -Name PSWindowsUpdate -AllVersions -Force
Step 6 — Configure a Persistent PowerShell Profile
A PowerShell profile is a script that runs automatically every time you open a new PowerShell session. Use it to set aliases, import modules you always need, and configure your prompt. There are separate profile files for Windows PowerShell 5.1 and PowerShell 7.
# View the profile file paths for the current shell
$PROFILE | Select-Object *
# The four profile scope variables:
# $PROFILE.AllUsersAllHosts — applies to all users, all hosts
# $PROFILE.AllUsersCurrentHost — applies to all users, current host
# $PROFILE.CurrentUserAllHosts — applies to current user, all hosts
# $PROFILE.CurrentUserCurrentHost — applies to current user, current host (most common)
# Create the profile file if it does not already exist
if (-not (Test-Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
# Open the profile for editing
notepad $PROFILE
# or: code $PROFILE (if VS Code is installed)
# Example profile content to add:
@'
# Set default location
Set-Location C:Scripts
# Import commonly used modules
Import-Module PSWindowsUpdate -ErrorAction SilentlyContinue
# Useful aliases
Set-Alias -Name ll -Value Get-ChildItem
Set-Alias -Name grep -Value Select-String
# Custom prompt showing username, hostname, and current path
function prompt {
$user = $env:USERNAME
$host = $env:COMPUTERNAME
$path = (Get-Location).Path
Write-Host "[$user@$host] " -ForegroundColor Cyan -NoNewline
Write-Host $path -ForegroundColor Yellow -NoNewline
return "> "
}
'@ | Set-Content $PROFILE
# Reload the profile in the current session
. $PROFILE
Step 7 — Enable PSReadLine for Command History and Autocompletion
PSReadLine is included with Windows Server 2025 and provides intelligent command history, syntax highlighting, and autocompletion. Configure it in your profile for a significantly improved interactive experience.
# Check PSReadLine version (2.x should be pre-installed on Server 2025)
Get-Module PSReadLine -ListAvailable
# Update PSReadLine if needed
Install-Module PSReadLine -Force -AllowPrerelease -Scope CurrentUser
# Add these settings to your $PROFILE for persistent configuration:
# Enable predictive IntelliSense (shows command predictions in grey)
Set-PSReadLineOption -PredictionSource History
# Use arrow keys to navigate history matching the current typed text
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# Show completions in a list view (Tab key)
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
# Enable syntax highlighting colours
Set-PSReadLineOption -Colors @{
Command = 'Cyan'
Parameter = 'DarkCyan'
String = 'Green'
Variable = 'Yellow'
Error = 'Red'
}
# View command history stored on disk
Get-Content (Get-PSReadLineOption).HistorySavePath | Select-Object -Last 50
Step 8 — Use Get-Help and Update-Help
PowerShell’s built-in help system is one of its most valuable features. On a fresh installation, help content is minimal — download the full documentation immediately.
# Download full help documentation for all installed modules
# Run as Administrator — content is saved to C:WindowsSystem32...
Update-Help -Force -ErrorAction SilentlyContinue
# Basic help for a cmdlet
Get-Help Get-Service
# Detailed help with all parameter descriptions
Get-Help Get-Service -Detailed
# Full help including examples and notes
Get-Help Get-Service -Full
# Show only examples
Get-Help Get-Service -Examples
# Open help in a separate GUI window
Get-Help Get-Service -ShowWindow
# Find all cmdlets related to a topic
Get-Help *firewall*
Get-Command -Noun FirewallRule
Step 9 — Essential Server Management Cmdlets Overview
These are the cmdlets you will use most frequently when administering Windows Server 2025. Familiarise yourself with them early — they replace dozens of legacy command-line tools.
# ── Service management ──────────────────────────────────────────────────────
Get-Service # List all services
Get-Service -Name "W32Time" # Specific service
Start-Service -Name "Spooler"
Stop-Service -Name "Spooler" -Force
Restart-Service -Name "Spooler"
Set-Service -Name "Spooler" -StartupType Disabled
# ── Process management ───────────────────────────────────────────────────────
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Stop-Process -Name "notepad" -Force
Start-Process -FilePath "notepad.exe"
# ── Event log ────────────────────────────────────────────────────────────────
Get-EventLog -LogName System -Newest 20 -EntryType Error
Get-WinEvent -FilterHashtable @{ LogName='Security'; Id=4625 } -MaxEvents 10
# ── Disk and volume management ───────────────────────────────────────────────
Get-Disk
Get-Volume
Get-PSDrive
Get-PhysicalDisk
# ── Network management ───────────────────────────────────────────────────────
Get-NetAdapter
Get-NetIPAddress
Test-NetConnection -ComputerName "8.8.8.8" -Port 443
# ── User and group management ─────────────────────────────────────────────────
Get-LocalUser
Get-LocalGroup
Get-LocalGroupMember -Group "Administrators"
# ── Computer information ──────────────────────────────────────────────────────
Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, TotalPhysicalMemory
systeminfo
Conclusion
A well-configured PowerShell environment on Windows Server 2025 dramatically reduces the time required for day-to-day administration and makes automation genuinely accessible. With Windows PowerShell 5.1 and PowerShell 7 running side by side, the correct execution policy set, a tailored profile loaded at startup, PSReadLine providing intelligent history, and a comprehensive library of modules available from PSGallery, you have everything you need to manage any aspect of the server from the command line. Take the time now to build these habits — writing scripts instead of clicking through wizards, using Get-Help before searching online, and storing your profile in version control — and you will have a consistent, reproducible management foundation that scales across every server in your environment.