Generic PowerShell

Get WSUS server
(Get-ItemProperty hklm:\software\policies\microsoft\windows\windowsupdate).WUserver

Get PowerShell Version

List Environmental Variables
$env:PSModulePath -split “;”

Enable Remote Desktop (using PSEXEC.exe for remote connection)
SetItemProperty Path “HKLM:\System\CurrentControlSet\Control\Terminal Server” Name “fDenyTSConnections”Value 0

Enable Remote Desktop using Invoke-Command
InvokeCommandComputername “comp1, “comp2” –ScriptBlock {SetItemProperty Path “HKLM:\System\CurrentControlSet\Control\Terminal Server” Name “fDenyTSConnections”Value 0}

Get-ItemProperty “hklm:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” | select WUServer
Get the WSUS server name from WSUS client

Get-WmiObject win32_computersystem | Select Manufacturer,Model | ft -auto
Get vendor and model of computer/server

Get-WmiObject win32_SystemEnclosure | select serialnumber | ft -auto
Get Serial Number of computer/server

or if that returns the error “To Be Filled By O.E.M.” try this instead:

gwmi win32_bios

Get-wmiobject -namespace “root\cimv2” -class win32_service | where startname -like *cold* | ft name,processid,startname -auto
Find services running with a domain credential, with a match to a domain name

Enable Hyper-V guest service interface on all guests on a host
get-vm -ComputerName  | Enable-VMIntegrationService -name “Guest Service Interface”

List installed Windows features
get-windowsfeature | where Installed

Get OS Version
(Get-WmiObject -class Win32_OperatingSystem).Caption

Get installation date of Windows OS
gcim Win32_OperatingSystem | select InstallDate

([WMI]”).ConvertToDateTime((Get-WmiObject Win32_OperatingSystem).InstallDate)

Remove the … from output
$FormatEnumerationLimit =-1

Import module for IIS
Import-Module WebAdministration
Otherwise you get the error “cd : Cannot find drive. A drive with the name ‘IIS’ does not exist.” when you type cd IIS:

Get the serial number of your client/server:
Get-WmiObject win32_SystemEnclosure | select serialnumber

Clear a variable value:
clv cn (use this to clear the $cn variable – i.e. always drop the $ from the variable name.

Get the VMs running on remove Hyper-V hosts that require the Integration Update Services to be upgraded:
get-vm -ComputerName server1, server2, server3 | where-object {$_.IntegrationServicesState -eq ‘Update Required’} | select-object computername, name, IntegrationServicesState | ft -auto

Get a list of vCPUs for each VM and whether CPU Compatibility mode is enabled:
Get-VMProcessor * | select vmname, CompatibilityForMigrationEnabled | sort CompatibilityForMigrationEnabled | ft -auto

Disclaimer: provided “AS IS” with no warranties and confer no rights