What you will learn in this TP
- Discover cmdlets with Get-Command and Get-Member
- Filter, sort and export objects
- Write a parameterized script and run it remotely
Introduction #
What you will learn in this section
- Discover cmdlets with Get-Command and Get-Member
- Filter, sort and export objects
- Write a parameterized script and run it remotely
Context. Your manager asks for a server status report before a migration. Rather than clicking through each console, you write a reusable inventory script.
Prerequisites: a disposable Windows Server 2025 virtual machine (free evaluation) with an administrator account, and PowerShell open as administrator · Estimated duration: 45 min
AnInventaire.ps1 script, a CSV report and an HTML page.Setup #
Guided steps, with their solution.
1. Prepare the workspace
Why? A dedicated folder avoids mixing scripts and reports.
CreateC:\TP\ScriptsandC:\TP\Rapports, check the PowerShell version and allow local scripts.2. Explore the system
Why? Get-Member reveals available properties before selecting them.
Display the server’s name, version, build, total memory and last boot.3. Disks and services
Why? The two most frequent incident causes: full disk and stopped service.
List volumes with their free percentage, then automatic services that are not running.4. Write the script
Why? A parameterized script can be reused and run remotely.
WriteC:\TP\Scripts\Inventaire.ps1returning one object per server (system, RAM, free C disk, number of stopped automatic services, latest update).5. Produce the reports
Why? CSV opens in a spreadsheet, HTML can be shared.
Export the result as timestamped CSV and HTML inC:\TP\Rapports.6. Run remotely
Why? Invoke-Command queries several servers in parallel.
Run the script on the local server and a second machine (orlocalhosttwice if you only have one), then gather the results.
Difficulty level : ●○○○○ (1/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
PowerShell for Windows administrators
Master PowerShell to administer Windows: cmdlets and help, object pipeline, filters and formats, ...
Windows and Windows Server: versions, editions and architecture
Discover the Windows ecosystem for administrators: Windows 11 and Windows Server 2025, editions a...
Windows storage: disks, volumes, Storage Spaces and RAID
Manage storage on Windows: GPT and MBR, partitions and volumes with PowerShell, NTFS and ReFS, St...
Windows updates and security: WSUS, Defender, BitLocker, LAPS and hardening
Maintain and secure a Windows estate: update strategy (Windows Update, WSUS, Azure Update Manager...
Active Directory Domain Services and DNS
Understand and deploy Active Directory: forest, domains, organizational units, domain controllers...
Services, scheduled tasks, event logs and performance
Control Windows services and their recovery, automate with Task Scheduler, use event logs with Ge...
Backup, Hyper-V and Windows troubleshooting
Back up and restore with Windows Server Backup (including system state and Active Directory), vir...
Windows networking: IP, DNS, DHCP, firewall and remote access
Configure and troubleshoot Windows networking with PowerShell, deploy a DHCP server, master Windo...
Windows administration best practices
The production checklist for Windows and Windows Server: installation, identity and Active Direct...