Recipes
Complete scripts for common needs, written in the PoshCode style and built on the CIM cmdlets.
System
- Last boot time and uptime
Date of the last Windows boot and the time elapsed since, locally and on several computers.
- Windows version and build
Edition, version number, build and architecture of Windows, locally and on several computers.
- Serial number and BIOS version
Manufacturer, model, serial number, BIOS version and date of a computer.
- Time zone and UTC offset
Configured time zone, current offset from UTC and daylight saving time status.
Hardware
- Disk space of all volumes, with the free percentage
Capacity, free space and free percentage of every local volume, from the fullest to the emptiest.
- Installed memory, module by module
Slot, capacity, manufacturer, type and speed of each memory module, with the total.
- Physical disks, partitions and drives
Link each physical disk to its partitions and lettered drives with Get-CimAssociatedInstance.
- Battery status
Remaining charge, status and estimated runtime of a laptop battery.
Network
- IP, DNS and gateway configuration of active adapters
IP addresses, mask, gateway, DNS and DHCP servers of the network adapters that have IP enabled.
- Network shares of a computer
List of shares with their local path, separating user shares from administrative shares.
Software and updates
- Installed Windows hotfixes
List of the hotfixes (KB) installed on a computer, and a check for a specific one.
- Installed programs, read from the registry
List of installed programs from the Uninstall registry keys, without using Win32_Product.
- Programs that run at startup
Commands run at sign-in: registry Run keys and Startup folders.
Users
- Local accounts, groups and members
Local user accounts, local groups and their members, with Get-CimAssociatedInstance and Win32_GroupUser.
- Open sessions on a computer
Interactive and Remote Desktop sessions, with the user and the sign-in time.
- User profiles and last use
Profiles on a computer, with the account (SID translated to a name), the folder and the last use date.
Processes and services
- Top memory processes with their owner
The ten processes using the most memory, and the account they run under, through the GetOwner method.
- Restart a service with -WhatIf
Stop then start a service with the StopService and StartService methods of Win32_Service, first as a dry run.
- Stopped automatic services across several servers
List, with one CIM session per server, the services set to start automatically that are not running.
Monitoring
- Get notified when a process starts
Watch for process starts with Register-CimIndicationEvent, Wait-Event or -Action, then clean up the subscription.
Fleet
- Hardware inventory of a computer as a single object
Operating system, model, BIOS, processor, memory and disks of a computer, gathered into a single object.
- Inventory of several computers in parallel
Query a list of computers with one CIM session per machine and ForEach-Object -Parallel, then export to CSV.