PowerShell needs no introduction — it's the configuration management and task automation framework of choice for the Windows environment. It combines the flexibility of a powerful scripting language with the power and speed of the command line to help IT admins orchestrate, automate and troubleshoot common IT functions. PowerShell commands are crucial.
One of the most efficient ways of getting good at PowerShell is by understanding the basics. getting proficient in syntax, understanding how variables work, becoming extra efficient by using the aliases available on many of these PowerShell commands. Knowing the absolute fundamentals can help build your foundation of knowledge and prowess by becoming more efficient and productive, especially when you need to 'process' larger and larger data sets. On to the future with PowerShell here are top 10 commands to know
This displays the list of commands that correspond to the search parameter you entered. Admins can use this command by typing Get-Command followed by their search query. For instance, "Get-Command *-service*" displays all the commands associated with -service.
You can use PowerShell to search through directories. The Get-ChildItem command is a handy cmdlet to look for folders and files and quickly perform content-based searches without using File Explorer.
Well, let's just say the Get-Help command does exactly what you'd think: it gives you help. Running this by itself will provide you with the basic teachings around what Get-Help can do for you and how to use it in multiple ways. The Get-Help cmdlet displays help at the command line from content in help files on your computer. Without help files, Get-Help displays basic help about cmdlets and functions. You can also use Get-Help to display online help for cmdlets and functions.
The Copy-Item cmdlet lets you copy-paste files and folders and their contents to a different directory. To copy files and folders, type Copy-Item followed by the source -Path, -Destination parameter, and destination address.
Frequently we need to check that critical processes are running or investigate processes that we don't recognize. Whilst Task Manager and SysInternals Process Explorer are useful tools, we can check, and fix, a lot of issues with the Get-Process (alias ps) cmdlet.
You can use the Clear-Content cmdlet to delete the contents of a specified file without deleting the file itself. Useful for task automation where you have a hard-coded file name but want to have a clean file each time the script runs.
There can be incredibly useful information contained in the Windows event log when troubleshooting issues such as slow logon. But knowing where to look can be problematic since on recent operating systems there are upwards of 300 different active event logs where crucial information could be hiding – not just in the System or Application events logs like in the old days.
The default execution policy in PowerShell is set to Restricted. This prevents the execution of malicious scripts in the PowerShell environment. However, when you execute a local PowerShell script, you may encounter the 'execution script is disabled on this system' error. The Set-ExecutionPolicy cmdlets let you change the security levels for script execution.
This command provides you with the list of services installed on your system. If you include the -Name switch as well as the name of the service as parameters to the Get-Service command, Windows will display the state of the service.
By default, PowerShell uses C:\Users\Username as the default working directory. The Set-Location cmdlet lets you set the current working directory to a specified location. Useful if you want to run a script or command from a specific location without having to specify the path each time.
This is the odd one out in this list because it is not available by default: One has to have the ActiveDirectory PowerShell module installed although that is very simple via the "Add-WindowsFeature RSAT-AD-PowerShell" command (run elevated).
Get-ADUser and associated cmdlets, such as Get-ADGroupMember, allow us to check, and change, AD information and is particularly useful for querying large numbers of objects and producing a report (see Export-CSV later).
Join our WhatsApp Channel to get the latest news, exclusives and videos on WhatsApp
_____________
Disclaimer: Analytics Insight does not provide financial advice or guidance. Also note that the cryptocurrencies mentioned/listed on the website could potentially be scams, i.e. designed to induce you to invest financial resources that may be lost forever and not be recoverable once investments are made. You are responsible for conducting your own research (DYOR) before making any investments. Read more here.