You can use Get-WMIObject to create a high-level hardware report. Instead of submitting a specific device class name, you should use a generic device class that applies to all hardware devices: PS > Get-WmiObject -Class CIM_LogicalDevice | Select-Object...

You can use Copy-Item to quickly copy entire structures of registry keys and sub-keys in a matter of milliseconds. Take a look at this example – it creates a new registry key in HKCU and then copies a key with all of its values and sub-keys from...

You may sometimes get "Access Denied" exceptions, even though you have Admin privileges and used an elevated shell. For example, this can hit you when you are trying to enable security-relevant PowerShell settings, such as enabling PowerShell...

The [RegEx] type has a method called Replace(), which can be used to replace text by using regular expressions. This line would replace the last octet of an IP address with a new fixed value: PS > [ Regex ] :: Replace ( ' 192.168.1.200 ' ,...

If you would like to check the implications of stopping a service, you should have a look at its dependent services: ( Get-Service spooler ) . DependentServices Or use Select-Object: get-service Spooler | Select-Object -expand DependentServices To stop...

In a previous tip, you learned that Select-Object can find multiple matches. Here is a function called matches. You can submit a regular expressions pattern and all text piped into matches will be matched: $pattern = ' \b[A-Z0-9._%+-]+@[A-Z0-9.-]...

When you want to find matches based on regular expressions, PowerShell will only support the -match operator which finds the first match. There does not seem to be a -matches operator that returns all matches. You can use Select-Object like so to find...

Sometimes, you may need to have the event ID for a system event, though what you really need is the instance ID. For example, Get-EventLog will only support instance IDs, but no event IDs. Here is a function that can translate event IDs into instance...

PowerShell will keep a history of the commands you entered and then you can list the history with Get-History, configuring the maximum length of that history with $MaxHistoryCount. This will tell PowerShell to keep the last 1,000 command lines in your...

When you need to handle errors created by native commands, you can use a wrapper function like Call. It will automatically discover when a native command writes to the error stream and return a warning: function Call { $command = $Args -join " "...