{"id":7119,"date":"2022-09-08T16:47:20","date_gmt":"2022-09-08T14:47:20","guid":{"rendered":"https:\/\/lazyadmin.nl\/?p=7119"},"modified":"2024-10-25T16:44:53","modified_gmt":"2024-10-25T14:44:53","slug":"powershell-commands","status":"publish","type":"post","link":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/","title":{"rendered":"35+ PowerShell Commands you Must Know"},"content":{"rendered":"\n<p>PowerShell is a scripting language designed for system administration by Microsoft. These days, PowerShell can be used on multiple platforms and is used to perform or automate a wide range of tasks while using the different PowerShell commands<\/p>\n\n\n\n<p>With all the modules that you can load, there are a lot of PowerShell cmdlets. But what are the most common ones that you must know?<\/p>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">In this article<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f32f758e1fb\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\" style='display:none' id=\"ez-toc-cssicon-toggle-item-69f32f758e1fb\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#what-are-powershell-commands\" >What are PowerShell Commands?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#10-basic-commands-to-start-with\" >10 Basic Commands to start with<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#1-get-help\" >1. Get-Help<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#2-get-command\" >2. Get-Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#3-write-host\" >3. Write-Host<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#4-get-history\" >4. Get-History<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#5-get-content\" >5. Get-Content<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#6-where-object\" >6. Where-Object<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#7-format-list-format-table\" >7. Format-List \/ Format-Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#9-get-childitem\" >9. Get-ChildItem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#10-get-credential\" >10. Get-Credential<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#25-useful-powershell-commands\" >25 Useful PowerShell Commands<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#file-system-operations\" >File System Operations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#data-inputoutput\" >Data Input\/Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#system-and-process-management\" >System and Process Management<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#data-analysis-and-measurement\" >Data Analysis and Measurement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#data-conversion-and-transformation\" >Data Conversion and Transformation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#utility-functions\" >Utility Functions<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#bonus-tips\" >Bonus Tips<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#35-ctrl-space\" >35. Ctrl + Space<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#36-set-strictmode\" >36. Set-StrictMode<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#wrapping-up\" >Wrapping Up<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>In this article, I have listed more than 35 commands that are good to know. I have also created the best PowerShell Cheat Sheet that you can download for free in the article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"what-are-powershell-commands\"><\/span>What are PowerShell Commands?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PowerShell commands, better known as cmdlets, are the building blocks of PowerShell scripts and modules. Cmdlets are designed to perform specific tasks, such as retrieving information, modifying settings, or creating new instances.<\/p>\n\n\n\n<p>PowerShell cmdlets are designed to be easy to use and follow a consistent naming convention. Cmdlet names are made up of a verb and a noun, separated by a hyphen. For example, the <code>Get-Process<\/code> cmdlet is used to retrieve information about running processes, while the <code>Set-ExecutionPolicy<\/code> cmdlet is used to modify the PowerShell execution policy.<\/p>\n\n\n\n<p>PowerShell also supports running traditional command-line tools and scripts. This allows users to leverage existing tools and scripts within PowerShell scripts and modules.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"10-basic-commands-to-start-with\"><\/span>10 Basic Commands to start with<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We are going to start with the 10 basic PowerShell commands that are most useful during your daily work. Knowing these commands allows you to get more out of PowerShell and make your work a lot easier.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Get-Help &#8211; <\/strong>Displays help information about PowerShell cmdlets and concepts.<\/li>\n\n\n\n<li><strong>Get-Command &#8211;<\/strong> Lists all of the available cmdlets in PowerShell.<\/li>\n\n\n\n<li><strong>Write-Host<\/strong> &#8211; Writes output directly to the console or other host.<\/li>\n\n\n\n<li><strong>Get-History &#8211; <\/strong>Displays a list of previously executed commands.<\/li>\n\n\n\n<li><strong>Get-Content<\/strong> &#8211; Retrieves the contents of a file or other item.<\/li>\n\n\n\n<li><strong>Where-Object &#8211;<\/strong> Filters input objects based on specified criteria.<\/li>\n\n\n\n<li><strong>Format-List<\/strong> &#8211; Formats output as a list.<\/li>\n\n\n\n<li><strong>Format-Table &#8211; <\/strong> Formats output as a table.<\/li>\n\n\n\n<li><strong>Get-ChildItem &#8211;<\/strong> Lists the items in a specified location.<\/li>\n\n\n\n<li><strong>Get-Credential &#8211;  <\/strong>Prompts the user for credentials.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1-get-help\"><\/span>1. Get-Help<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Get-Help<\/code> cmdlet displays detailed help information about PowerShell commands. It will show the syntax of the cmdlet and the parameters that you can use. It&#8217;s a great way to learn more about new cmdlets.<\/p>\n\n\n\n<p>For example, to display help information about the <code>Get-Credential<\/code> cmdlet, run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Help Get-Credential\n\n# Result\nNAME\n    Get-Credential\n\nSYNTAX\n    Get-Credential [-Credential] &lt;pscredential>  [&lt;CommonParameters>]\n    Get-Credential [[-UserName] &lt;string>] -Message &lt;string>  [&lt;CommonParameters>]\n\nALIASES\n    None<\/pre>\n\n\n\n<p>Most cmdlets also have examples that you can view using the Get-Help command. To view the examples you will need to add the parameter <code>-examples<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Help Connect-ExchangeOnline -Examples\n\n# Result\nNAME\n    Connect-ExchangeOnline\n\nSYNOPSIS\n    This cmdlet is available only in the Exchange Online PowerShell module. For more information, see About the Exchange Online PowerShell module (https:\/\/aka.ms\/exov3-module).\n    -------------------------- Example 1 --------------------------\n    Connect-ExchangeOnline -UserPrincipalName chris@contoso.com\n\n    This example connects to Exchange Online PowerShell using modern authentication, with or without multi-factor authentication (MFA). We aren't using the UseRPSSession parameter, so the connection uses REST and doesn't require Basic authentication to be enabled in WinRM on the local computer.\n    -------------------------- Example 2 --------------------------\n    Connect-ExchangeOnline -UserPrincipalName chris@contoso.com -UseRPSSession<\/pre>\n\n\n<script async src=\"https:\/\/alatus.eocampaign1.com\/form\/ae21fac8-606b-11ef-9aaf-f7237224cd89.js\" data-form=\"ae21fac8-606b-11ef-9aaf-f7237224cd89\"><\/script>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-get-command\"><\/span>2. Get-Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Get-Command<\/code> cmdlet lists all of the available cmdlets in PowerShell. This command can be used to explore available cmdlets and to learn more about their parameters and usage.<\/p>\n\n\n\n<p>To list all of the available cmdlets that contain the word &#8220;process&#8221; in their name, run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Command *process*<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-write-host\"><\/span>3. Write-Host<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Write-Host<\/code> cmdlet writes output directly to the console. This command can be used to display information to the user or to show information for troubleshooting purposes. Besides Write-Host, you can also use Write-Warning to write a warning message or Write-Error for error messages.<\/p>\n\n\n\n<p>To write the text &#8220;Hello, World!&#8221; to the console, run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Write-Host \"Hello, World!\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4-get-history\"><\/span>4. Get-History<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When working in PowerShell, you probably often use the up arrow key to find that one command that you used earlier. The longer you have been working in your PowerShell session, the more commands you might have to go through.<\/p>\n\n\n\n<p>But did you know that you can use the <code>Get-History<\/code> cmdlet to view all commands that you have used? PowerShell keeps track of commands that you enter during a session. By default, it will remember the last 4096 entries!<\/p>\n\n\n\n<p>Just type Get-History to view all the last commands that you have used:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-History<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"873\" height=\"356\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33.jpg\" alt=\"Get History command\" class=\"wp-image-7129\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33.jpg 873w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33-300x122.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33-768x313.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33-800x326.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33-400x163.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_12h11_33-50x20.jpg 50w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><figcaption class=\"wp-element-caption\">Get-History<\/figcaption><\/figure>\n\n\n\n<p>In the example, I only have 8 entries, so it&#8217;s easy to find the command you are looking for. But when you have more entries, then it&#8217;s good to know that we can also search\/filter the <code>Get-History<\/code> cmdlet, by piping a <code>Where-object<\/code> to it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-History | Where-Object {$_.Commandline -like \"*EXOMailbox*\"}\n\n# Result\n  Id CommandLine\n  -- -----------\n   4 Get-EXOMailbox -Filter \"RecipientType -eq 'UserMailbox'\"\n   6 Get-EXOMailbox -Filter \"RecipientType -eq 'UserMailbox'\"\n   7 Get-EXOMailbox -Filter \"RecipientType -eq 'UserMailbox'\" | Select Name,EmailAddresses<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5-get-content\"><\/span>5. Get-Content<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Get-Content<\/code> cmdlet retrieves the contents of a file or other item. This command can be used to read the contents of a file or to retrieve other types of data.<\/p>\n\n\n\n<p>To retrieve the contents of a file named &#8220;example.txt&#8221;, run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Content example.txt<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6-where-object\"><\/span>6. Where-Object<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Where-Object<\/code> cmdlet filters input objects based on specified criteria. This command can be used to select specific items from a larger set of data. Often when you retrieve information from a system or resource, more than one record is returned. By piping the Where-Object cmdlet behind it we can filter the results.<\/p>\n\n\n\n<p>For example, to get all files that are larger than 10 MB from the given directory, we can run the command below. The Get-ChildItem will get all the files, whereas the Where-Object cmdlet selects only the files that are greater than -gt the given size.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$path = \"C:\\temp\\files\\\"\n\n# Set file size\n$sizeInMb = 10\n\n# Calculate actual file size\n$size = $sizeInMb*1024*1024\n\n# Delete all files that are larger then given size\nGet-ChildItem -Path $Path -Recurse -File | Where-Object { $_.length -gt $size }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7-format-list-format-table\"><\/span>7. Format-List \/ Format-Table<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Format-List<\/code> and <code>Format-Table<\/code> cmdlets format the output of a command as either a list or table. Formatting the output makes the results easier to read.<\/p>\n\n\n\n<p>Format-List, in short <code>fl<\/code>, is often used when you want to see all the results of a cmdlet. Cmdlets in PowerShell often only return a selection of the data. By piping the <code>Format-Lis<\/code>t cmdlet behind it, you can see all the data. For example, the cmdlet Get-LocalUser returns only the basic information of the user account:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-LocalUser Admin\n\n# Result\nName  Enabled Description\n----  ------- -----------\nadmin False<\/pre>\n\n\n\n<p>But when we add Format-List behind it, we can see all the information of the user account:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-LocalUser Admin | fl\n\n# Result\nAccountExpires         :\nDescription            :\nEnabled                : False\nFullName               :\nPasswordChangeableDate : 27-6-2019 12:20:44\nPasswordExpires        :\nUserMayChangePassword  : True\nPasswordRequired       : False\nPasswordLastSet        : 27-6-2019 12:20:44\nLastLogon              : 27-9-2022 13:43:46\nName                   : admin\nSID                    : S-1-5-21-3190960386-960769250-3760335402-1001\nPrincipalSource        : Local<\/pre>\n\n\n\n<p>Format-Table will format the results into a table. Most cmdlets that return multiple entries will format the result by default into a table. Otherwise, you can use the <code>Format-Table<\/code> cmdlet. If the columns don&#8217;t fit in your console, then it can help to add the <code>-Autosize<\/code> parameter to the cmdlet<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Hotfix | ft -AutoSize<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"9-get-childitem\"><\/span>9. Get-ChildItem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Get-ChildItem<\/code> command is used to retrieve a list of files and\/or directories in a specified path. It is similar to the dir command in Command Prompt. Only the advantage of the Get-ChildItem cmdlet is that we can use filter and other parameters to select only the results that we need.<\/p>\n\n\n\n<p>For example, to get all txt files from the directory c:\\test and its subfolders, we can use the command below in PowerShell:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-ChildItem -Path C:\\Test\\*.txt -Recurse<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"10-get-credential\"><\/span>10. Get-Credential<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Get-Credential<\/code> command is used to prompt the user for a username and password. It returns a PSCredential object that can be used to authenticate the user in other commands.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$cred = Get-Credential\nConnect-MsolService -Credential $cred<\/pre>\n\n\n\n<p>This will prompt the user for a username and password, and then use the returned credentials to connect to Microsoft Online Services.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"25-useful-powershell-commands\"><\/span>25 Useful PowerShell Commands<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are <strong>more than 200 PowerShell<\/strong> commands that we can use. I am not going to list all of them in this article, but here are the <strong>25 most useful<\/strong> commands in categories for you:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"file-system-operations\"><\/span>File System Operations<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">11. Copy-Items<\/h4>\n\n\n\n<p>The <code>Copy-Item<\/code> cmdlet is used to copy files and directories from one location to another. It allows you to specify the source and destination locations and also provides options to overwrite existing files or retain their attributes. This is useful when you need to back up or transfer files and directories.<\/p>\n\n\n\n<p>Learn more about the <a href=\"https:\/\/lazyadmin.nl\/powershell\/copy-file\/\">Copy-Item cmdlet in this article<\/a>.<\/p>\n\n\n\n<p>For example, the command below makes a copy of the documents folder to the folder d:\\backup.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Copy-Item -Path C:\\data\\documents -Destination d:\\backup -Recurse<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">12. Move-Item<\/h4>\n\n\n\n<p>We can also move items with PowerShell, with the help of the <code>Move-Item<\/code> cmdlet. It is similar to the <code>Copy-Item<\/code> cmdlet but instead of creating a copy, it moves the files and directories to the new location. This is useful when you need to move files and directories within your computer or between different computers.<\/p>\n\n\n\n<p>Suppose you want to move a file named &#8216;report.docx&#8217; from your desktop to a folder named &#8216;documents&#8217;. You can use the following command to move the file to the &#8216;documents&#8217; folder.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Move-Item -Path C:\\users\\username\\desktop\\report.docx -Destination C:\\data\\documents<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">13. Remove-Item<\/h4>\n\n\n\n<p>The <code>Remove-Item<\/code> cmdlet is used to delete a file or a directory. It can also delete files within a directory and its subdirectories. You can use the <code>-Recurse<\/code> parameter to remove directories and their contents recursively. It can also delete read-only files, hidden files, and system files. However, it will prompt you for confirmation before deleting any read-only or hidden files.<\/p>\n\n\n\n<p>Learn more about the <a href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-delete-file\/\">Remove-Item cmdlet in this article<\/a>.<\/p>\n\n\n\n<p>To delete a file, you can use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Remove-Item C:\\Temp\\file.txt<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">14. Test-Path<\/h4>\n\n\n\n<p>The <code>Test-Path<\/code> cmdlet is used to check if a file or a directory exists at a specified location. It returns <code>True<\/code> if the file or directory exists, and <code>False<\/code> if it doesn&#8217;t exist. When working with files or directories you should really be using the cmdlet a lot. Read all about the <a href=\"https:\/\/lazyadmin.nl\/it\/test-path\/\">Test-Path cmdlet in this article<\/a>.<\/p>\n\n\n\n<p>To check if a file exists, you can use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Test-Path C:\\Temp\\file.txt<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">15. New-PSDrive<\/h4>\n\n\n\n<p>The <code>New-PSDrive<\/code> cmdlet is used to create a new Windows PowerShell drive that is &#8220;mapped&#8221; to a location in a data store, such as a network drive, a directory on the local computer, or a registry key. The drive that is created behaves like a normal Windows drive and can be accessed by using standard Windows commands.<\/p>\n\n\n\n<p>For example, to create a new drive that maps to a network share, you can use the command below in PowerShell. Learn more about the <a href=\"https:\/\/lazyadmin.nl\/powershell\/new-psdrive\/\">New-PSDrive cmdlet in this article<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">New-PSDrive -Name \"N\" -PSProvider FileSystem -Root \"\\\\Server\\Share\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"data-inputoutput\"><\/span>Data Input\/Output<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">16. Get-Content<\/h4>\n\n\n\n<p>The <code><a href=\"https:\/\/lazyadmin.nl\/powershell\/get-content\/\">Get-Content<\/a><\/code> cmdlet reads the content of a file and returns it as an object. You can use this cmdlet to read text files, log files, and other types of files. By default, <code>Get-Content<\/code> returns the contents of a file as a single string. However, you can use the <code>-Delimiter<\/code> parameter to split the file into individual lines or other segments.<\/p>\n\n\n\n<p>Learn more about the Get-Content cmdlet in <a href=\"https:\/\/lazyadmin.nl\/powershell\/get-content\/\">this article<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Read the contents of a text file\nGet-Content -Path \"C:\\Temp\\example.txt\"\n\n# Read the contents of a file and display only the first 5 lines\nGet-Content -Path \"C:\\Temp\\example.txt\" -TotalCount 5\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">17. Get-Clipboard<\/h4>\n\n\n\n<p>The <code>Get-Clipboard<\/code> cmdlet retrieves the contents of the Windows clipboard. You can use this cmdlet to get text, images, and other types of data that have been copied to the clipboard.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Get the contents of the clipboard as text\nGet-Clipboard -Format Text\n\n# Get the contents of the clipboard as an image\nGet-Clipboard -Format Image<\/pre>\n\n\n\n<p>But we can not only retrieve data from the Clipboard, we can also copy data to the clipboard with PowerShell. Simply pipe <code>clip<\/code> behind your command to store the results on your clipboard:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Content -path \"c:\\temp\\fruits.txt\" | clip<\/pre>\n\n\n\n<p>You can now simply paste the contents into any program that you want. To view\/paste the contents of the clipboard in PowerShell use <code>Get-Clipboard<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Clipboard\n\n# Result\nBlueBerry;StrawBerry;BlackBerry;RaspBerry;CranBerry;<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"873\" height=\"251\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55.jpg\" alt=\"PowerShell command Get-clipboard\" class=\"wp-image-7133\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55.jpg 873w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55-300x86.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55-768x221.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55-800x230.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55-400x115.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_13h58_55-50x14.jpg 50w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><figcaption class=\"wp-element-caption\">clip command in PowerShell<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">18. Out-File<\/h4>\n\n\n\n<p>The <code>Out-File<\/code> cmdlet sends output to a file. You can use this cmdlet to save the output of a command or script to a text file, CSV file, or other types of file. For CSV files it&#8217;s better to use the <code>Export-CSV<\/code> cmdlet though.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Save the output of a command to a text file\nGet-Service | Out-File -FilePath \"C:\\Temp\\services.txt\"\n\n# Save the output of a command to a CSV file\nGet-Process | Select-Object Name, CPU | Out-File -FilePath \"C:\\Temp\\processes.csv\" -Encoding UTF8\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">19. Out-GridView<\/h4>\n\n\n\n<p>When testing scripts or working in PowerShell we often output the result directly in the console. We can format the result set as a table with format-table or in short ft. But with large data sets, this isn&#8217;t always the best option. Data may be truncated or columns are missing in your overview.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"873\" height=\"491\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6.png\" alt=\"format table\" class=\"wp-image-7134\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6.png 873w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6-300x169.png 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6-768x432.png 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6-800x450.png 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6-400x225.png 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-6-50x28.png 50w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><figcaption class=\"wp-element-caption\">Default table output in PowerShell<\/figcaption><\/figure>\n\n\n\n<p>The grid view output is a great solution to that. It will output all the data in a nice searchable, sortable view in a new window. The table contains all columns, which you can sort and search through.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-EXOMailbox | Out-Gridview<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"455\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-1024x455.png\" alt=\"out-gridview\" class=\"wp-image-7135\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-1024x455.png 1024w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-300x133.png 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-768x341.png 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-800x355.png 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-400x178.png 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7-50x22.png 50w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-7.png 1427w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">PowerShell Out-Gridview<\/figcaption><\/figure>\n\n\n\n<p>In the top left corner, you can add filters to the result set, allowing you to easily find the correct data that you need:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"911\" height=\"267\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23.jpg\" alt=\"filter grid view\" class=\"wp-image-7136\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23.jpg 911w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23-300x88.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23-768x225.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23-800x234.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23-400x117.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h09_23-50x15.jpg 50w\" sizes=\"(max-width: 911px) 100vw, 911px\" \/><figcaption class=\"wp-element-caption\">Grid-view filter<\/figcaption><\/figure>\n\n\n\n<p>Now the best part of the gridview in PowerShell, we can select the items we need and pass them back to PowerShell. For this, you will need to add the parameter <code>-PassThru<\/code> to the cmdlet:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-EXOMailbox | Out-Gridview -PassThru<\/pre>\n\n\n\n<p>Select the records that you need and press Ok. You can just pipe a select behind it, or store the results in a variable.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"809\" height=\"251\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46.jpg\" alt=\"powershell commands\" class=\"wp-image-7137\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46.jpg 809w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46-300x93.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46-768x238.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46-800x248.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46-400x124.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_14h14_46-50x16.jpg 50w\" sizes=\"(max-width: 809px) 100vw, 809px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">20. Import-CSV<\/h4>\n\n\n\n<p>The <code>Import-CSV<\/code> cmdlet is used to import data from a CSV file to PowerShell. It converts the CSV file data into an object that can be easily manipulated using other cmdlets. This is useful when you need to work with large datasets that are stored in a CSV file.<\/p>\n\n\n\n<p>Read more about the Import-CSV cmdlet <a href=\"https:\/\/lazyadmin.nl\/powershell\/import-csv-powershell\/\">in this article<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Import-CSV C:\\data\\employees.csv | Format-Table<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">21. Export-CSV<\/h4>\n\n\n\n<p>The Export-CSV command is also one of those commands that is great to use when you are retrieving data with PowerShell. We all know that Excel is great when it comes to processing data further. The Export-CSV command generates a CSV file from your data.<\/p>\n\n\n\n<p>Add the NoTypeInformation and Encoding parameter behind it. The first will remove the header information in your CSV file and the latter makes sure that the right encoding is used.<\/p>\n\n\n\n<p>Read more about <a href=\"https:\/\/lazyadmin.nl\/powershell\/export-csv-in-powershell\/\">Export-CSV in this article<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-EXOMailbox | Export-CSV -path c:\\temp\\mailbox.csv -NoTypeInformation -Encoding UTF8<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"system-and-process-management\"><\/span>System and Process Management<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">22. Enter-PSSession<\/h4>\n\n\n\n<p>Need to run a PowerShell command on the server? Most open a remote desktop, to start a PowerShell session on the server, but there is really no need for that. With PowerShell, we can start an interactive session with a remote computer using the <code>Enter-PSSession<\/code> cmdlet.<\/p>\n\n\n\n<p>To start an interactive session, simply type:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Enter-PSSession -Computername LazySrvLab02\n\n# Result\n[LazySrvLab02]: PS C:\\><\/pre>\n\n\n\n<p>You can now run PowerShell commands on the server, just as if you are working directly on the server. If you need to authenticate with different credentials, then use the parameter <code>-credential<\/code> to specify the username that you want to use. You will be prompted for the password.<\/p>\n\n\n\n<p>To exit the remote session, type <code>Exit-PSSession<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">23. Start-Process<\/h4>\n\n\n\n<p>The <code>Start-Process<\/code> cmdlet is used to start a new process, such as an executable file or a script, and optionally pass it arguments. You can specify the file path, arguments, working directory, and other parameters when starting the process. This cmdlet is useful when you need to start a process from a script or command line.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Start-Process -FilePath \"C:\\Program Files\\MyApp\\MyApp.exe\" -ArgumentList \"-Option1\", \"-Option2\"<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">24. Start-Transcript<\/h4>\n\n\n\n<p>The <code>Start-Transcript<\/code> cmdlet creates a transcript of a PowerShell session, which includes all commands entered and their output. The transcript is saved to a text file.<\/p>\n\n\n\n<p>To create a transcript you will need to run the command below to start recording. When done, you can use the cmdlet <code>Stop-Transcript<\/code>. Learn more about <a href=\"https:\/\/lazyadmin.nl\/powershell\/start-transcript\/\">Start-Transcript in this article<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Start-Transcript -Path C:\\transcript.txt<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">25. Start-Sleep<\/h4>\n\n\n\n<p>The <code>Start-Sleep<\/code> cmdlet pauses a PowerShell session for a specified amount of time. This is useful for creating scripts that need to wait for a certain amount of time before executing the next command.<\/p>\n\n\n\n<p>The command below pauses the script for 10 seconds. Learn more about the PowerShell Start-Sleep command in <a href=\"https:\/\/lazyadmin.nl\/powershell\/start-sleep\/\">this article<\/a>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Start-Sleep -Seconds 10<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">26. Set-Alias<\/h4>\n\n\n\n<p>The <code>Set-Alias<\/code> cmdlet creates or changes an alias (alternate name) for a cmdlet or other command element in the current PowerShell session. This can help to save time typing long command names or to create custom abbreviations for frequently used commands.<\/p>\n\n\n\n<p>In this example, we create an alias <code>l<\/code> for the <code>ls<\/code> command. Now instead of typing <code>ls<\/code> to list files, we can simply type <code>l<\/code>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Set-Alias -Name l -Value ls<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"data-analysis-and-measurement\"><\/span>Data Analysis and Measurement<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">27. Select-String<\/h4>\n\n\n\n<p>The <code>Select-String<\/code> cmdlet searches through a given input (text files, strings, etc.) for a specific string pattern and outputs any lines that match the pattern. This is similar to the <code>grep<\/code> command in Unix\/Linux systems.<\/p>\n\n\n\n<p>Let&#8217;s say you have a log file that you want to search for lines that contain the word &#8220;error&#8221;. You can use <code>Select-String<\/code> to do this. The command below will search through the log file and output any lines that contain the word &#8220;error&#8221;. Read more about the PowerShell Select-String command in <a href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\">this article.<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Path C:\\logs\\logfile.txt -Pattern \"error\"<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">27. Measure-Command<\/h4>\n\n\n\n<p>The <code>Measure-Command<\/code> cmdlet measures the time it takes for a command to run. This is useful for optimizing scripts and identifying performance bottlenecks.<\/p>\n\n\n\n<p>Let&#8217;s say you have a script that you want to optimize. You can use <code>Measure-Command<\/code> to measure the time it takes for a specific command to run. For example, the following command will measure the time it takes to copy a file from one location to another:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Measure-Command {Copy-Item -Path C:\\files\\file.txt -Destination D:\\backup\\file.txt}<\/pre>\n\n\n\n<p>The output of the command will show the elapsed time, as well as other statistics such as the CPU time used and the number of garbage collections performed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">28. Measure-Object<\/h4>\n\n\n\n<p>The <code>Measure-Object<\/code> cmdlet calculates the properties of numeric objects such as the sum, average, minimum, maximum, and standard deviation. It is useful for analyzing the output of other PowerShell commands.<\/p>\n\n\n\n<p>Suppose we want to calculate the average size of all the files in a directory. We can use the <code>Get-ChildItem<\/code> cmdlet to retrieve the files in the directory and pipe the output to the <code>Measure-Object<\/code> cmdlet to calculate the average size:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-ChildItem C:\\temp | Measure-Object -Property Length -Average<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">29. Compare-Object<\/h4>\n\n\n\n<p>The <code>Compare-Object<\/code> cmdlet compares two sets of objects and returns the differences. It is useful for finding differences between two sets of data.<\/p>\n\n\n\n<p>For example, let&#8217;s compare to array with fruits:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$fruits = \"apple\",\"kiwi\",\"pear\"\n$basket = \"kiwi\",\"raspbery\"\n\nCompare-Object -IncludeEqual $fruit $basket\n\n# Result\nInputObject SideIndicator\n----------- -------------\nkiwi        ==\nraspbery    =>\ngrape       &lt;=\npear        &lt;=<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">30. Sort-Object<\/h4>\n\n\n\n<p>The <code>Sort-Object<\/code> cmdlet sorts objects in ascending or descending order based on one or more properties. It can be used to sort any type of object, such as files, directories, registry keys, or PowerShell objects.<\/p>\n\n\n\n<p>In this example, we use <code>Get-ChildItem<\/code> to get a list of files and directories in the current directory. We then pipe that output to <code>Sort-Object<\/code> to sort the list by name in descending order, and finally use <code>Select-Object<\/code> to show only the first 10 items in the sorted list.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-ChildItem | Sort-Object -Property Name -Descending | Select-Object -First 10<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"data-conversion-and-transformation\"><\/span>Data Conversion and Transformation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">31. <strong>ConvertTo-Html<\/strong><\/h4>\n\n\n\n<p>The <code>ConvertTo-Html<\/code> cmdlet converts PowerShell objects into HTML format. It is useful for generating reports and displaying data in a more readable format.<\/p>\n\n\n\n<p>Suppose we want to generate an HTML report of the running processes on a computer. We can use the <code>Get-Process<\/code> cmdlet to retrieve the running processes and pipe the output to the <code>ConvertTo-Html<\/code> cmdlet to generate an HTML report:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Process | ConvertTo-Html | Out-File C:\\temp\\processes.html<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">32. <strong>ConvertTo-SecureString<\/strong><\/h4>\n\n\n\n<p>The <code>ConvertTo-SecureString<\/code> cmdlet converts a plaintext string to a secure string that can be used to store sensitive data, such as passwords or API keys, in a more secure way. It is useful for preventing unauthorized access to sensitive data.<\/p>\n\n\n\n<p>For example, we want to store a password in a variable for use in a script. We can use the <code>Read-Host<\/code> cmdlet to prompt the user for a password, and then pipe the output to the <code>ConvertTo-SecureString<\/code> cmdlet to convert it to a secure string:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$password = Read-Host \"Enter password\" -AsSecureString\n$cred = New-Object System.Management.Automation.PSCredential (\"username\", $password)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"utility-functions\"><\/span>Utility Functions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">33. Get-Random<\/h4>\n\n\n\n<p>When writing scripts it&#8217;s not uncommon to use a random function to generate a random integer. But the <code>Get-Random<\/code> cmdlet in PowerShell can do more than just generate an integer. It&#8217;s also capable of selecting a random entry from an array for example.<\/p>\n\n\n\n<p>The <strong>Get-Random<\/strong> cmdlet uses the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.security.cryptography.randomnumbergenerator\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">RandomNumberGenerator<\/a> class which allows it to generate cryptographically secure randomness.  It returns by default an integer between 0 and 2,147,483,647. But of course, we specify a minimum and maximum value.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-Random -Minimum -50 -Maximum 150\n\n# Result\n111<\/pre>\n\n\n\n<p>Get-Random can also be used to select a random item from an array:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$array = 'apple','pear','raspberry','kiwi','banana','melon','blueberry'\n\n$array | Get-Random\n\n# Result\nraspberry<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">34. Get-Date<\/h4>\n\n\n\n<p>The <code>Get-Date<\/code> cmdlet returns the current date and time on the local computer. You can use this cmdlet to perform date and time calculations and to display the date and time in a specific format.<\/p>\n\n\n\n<p>Make sure that your <a href=\"https:\/\/lazyadmin.nl\/powershell\/get-date\/\">read this article<\/a> to learn more about the Get-Date cmdlet.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Get the current date and time\nGet-Date\n\n# Get the date and time 10 days from now\nGet-Date -Date (Get-Date).AddDays(10)\n\n# Get the date and time in a specific format\nGet-Date -Format \"yyyy-MM-dd hh:mm:ss\"<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"bonus-tips\"><\/span>Bonus Tips<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"35-ctrl-space\"><\/span>35. Ctrl + Space<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This is not really a PowerShell command, but you wish that you knew about this key combination earlier. When using a cmdlet we all often type the hyphen <code>-<\/code> and then tab through all the possible parameters that the cmdlet has.<\/p>\n\n\n\n<p>But did you know you can view all parameters at once? To try this out, type a cmdlet and press <code>Ctrl + Space<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"873\" height=\"296\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5.png\" alt=\"best powershell commands\" class=\"wp-image-7130\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5.png 873w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5-300x102.png 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5-768x260.png 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5-800x271.png 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5-400x136.png 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/image-5-50x17.png 50w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><figcaption class=\"wp-element-caption\">Display all nouns and parameters<\/figcaption><\/figure>\n\n\n\n<p>It will display all nouns and parameters that you can use with the cmdlet. Now pressing Ctrl + Space is a method you will need to get used to, but you can also set the following in your <a href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-profile\/\">PowerShell profile<\/a>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Set-PSReadlineKeyHandler -Key Tab -Function Complete<\/pre>\n\n\n\n<p>This way you will only need to type the hyphen and <strong>press Tab twice<\/strong> to list all parameters. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"36-set-strictmode\"><\/span>36. Set-StrictMode<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The Set-StrictMode command in PowerShell establishes and enforces coding rules. By default, strict mode is turned off and that can cause a real mess. When strict mode is off, PowerShell threats uninitialized variables&nbsp;as <code>$null<\/code> or <code>0<\/code>, for example.<\/p>\n\n\n\n<p>Note the following code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$username = 'adelev'\nGet-EXOMailbox $usename | Set-mailbox -Hiddenfromaddresslist:$true<\/pre>\n\n\n\n<p>In the example above, I have misspelled the <code>$username<\/code> variable in the Get-ExoMailbox command. If Strict Mode is not enabled, PowerShell will handle the misspelled variable <code>$usename<\/code> as a <code>$null<\/code>, with the result that the cmdlet will get all mailboxes and hide them all from the address list.<\/p>\n\n\n\n<p>When you set StrictMode to version 2, PowerShell will instead throw an error that the variable is not set.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Set-StrictMode -Version 2<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"809\" height=\"251\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09.jpg\" alt=\"Top PowerShell Commands\" class=\"wp-image-7140\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09.jpg 809w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09-300x93.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09-768x238.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09-800x248.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09-400x124.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/2022-09-08_15h50_09-50x16.jpg 50w\" sizes=\"(max-width: 809px) 100vw, 809px\" \/><figcaption class=\"wp-element-caption\">Strict Mode set<\/figcaption><\/figure>\n\n\n\n<p>I recommend adding the <code>Set-StrictMode -Version 2<\/code> command to your <a href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-profile\/\">PowerShell Profile<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"wrapping-up\"><\/span>Wrapping Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>With PowerShell, we can always learn new things, and improve our scripts or work methods, to make our work easier. These PowerShell commands can really help you with that. Commands like <code>Set-StrictMode<\/code> and the full autocomplete function are one of the best commands to know and use.<\/p>\n\n\n\n<p>I hope you found this list with PowerShell commands useful or if you have any questions or suggestions, please drop a comment below!<\/p>\n<script async src=\"https:\/\/alatus.eocampaign1.com\/form\/d0ce5de8-9b48-11ee-8cf4-eb425eea7369.js\" data-form=\"d0ce5de8-9b48-11ee-8cf4-eb425eea7369\"><\/script>","protected":false},"excerpt":{"rendered":"<p>PowerShell is a scripting language designed for system administration by Microsoft. These days, PowerShell can be used on multiple platforms and is used to perform or automate a wide range of tasks while using the different PowerShell commands With all &#8230; <a title=\"35+ PowerShell Commands you Must Know\" class=\"read-more\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\">Read more<span class=\"screen-reader-text\">35+ PowerShell Commands you Must Know<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":7142,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[69],"tags":[22],"class_list":["post-7119","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"wppr_data":{"cwp_meta_box_check":"No"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>35+ PowerShell Commands you Must Know &#8212; LazyAdmin<\/title>\n<meta name=\"description\" content=\"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"35+ PowerShell Commands you Must Know &#8212; LazyAdmin\" \/>\n<meta property=\"og:description\" content=\"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"LazyAdmin\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-08T14:47:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-25T14:44:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"450\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rudy Mens\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/lazyadmin\" \/>\n<meta name=\"twitter:site\" content=\"@lazyadmin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rudy Mens\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\"},\"author\":{\"name\":\"Rudy Mens\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"headline\":\"35+ PowerShell Commands you Must Know\",\"datePublished\":\"2022-09-08T14:47:20+00:00\",\"dateModified\":\"2024-10-25T14:44:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\"},\"wordCount\":3353,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg\",\"keywords\":[\"Powershell\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\",\"url\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\",\"name\":\"35+ PowerShell Commands you Must Know &#8212; LazyAdmin\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg\",\"datePublished\":\"2022-09-08T14:47:20+00:00\",\"dateModified\":\"2024-10-25T14:44:53+00:00\",\"description\":\"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.\",\"breadcrumb\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg\",\"width\":800,\"height\":450},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lazyadmin.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"35+ PowerShell Commands you Must Know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lazyadmin.nl\/#website\",\"url\":\"https:\/\/lazyadmin.nl\/\",\"name\":\"LazyAdmin\",\"description\":\"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices\",\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lazyadmin.nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\",\"name\":\"Rudy Mens\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"width\":500,\"height\":500,\"caption\":\"Rudy Mens\"},\"logo\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\"},\"description\":\"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.\",\"sameAs\":[\"https:\/\/lazyadmin.nl\",\"https:\/\/www.facebook.com\/lazyadminnl\/\",\"http:\/\/nl.linkedin.com\/in\/rudymens\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"35+ PowerShell Commands you Must Know &#8212; LazyAdmin","description":"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/","og_locale":"en_US","og_type":"article","og_title":"35+ PowerShell Commands you Must Know &#8212; LazyAdmin","og_description":"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.","og_url":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/","og_site_name":"LazyAdmin","article_publisher":"https:\/\/www.facebook.com\/lazyadminnl\/","article_author":"https:\/\/www.facebook.com\/lazyadminnl\/","article_published_time":"2022-09-08T14:47:20+00:00","article_modified_time":"2024-10-25T14:44:53+00:00","og_image":[{"width":800,"height":450,"url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg","type":"image\/jpeg"}],"author":"Rudy Mens","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/lazyadmin","twitter_site":"@lazyadmin","twitter_misc":{"Written by":"Rudy Mens","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#article","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/"},"author":{"name":"Rudy Mens","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"headline":"35+ PowerShell Commands you Must Know","datePublished":"2022-09-08T14:47:20+00:00","dateModified":"2024-10-25T14:44:53+00:00","mainEntityOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/"},"wordCount":3353,"commentCount":2,"publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg","keywords":["Powershell"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/","url":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/","name":"35+ PowerShell Commands you Must Know &#8212; LazyAdmin","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg","datePublished":"2022-09-08T14:47:20+00:00","dateModified":"2024-10-25T14:44:53+00:00","description":"More then 35 PowerShell commands to get your started with writing scripts. Including free PowerShell Cheat Sheet.","breadcrumb":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#primaryimage","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg","width":800,"height":450},{"@type":"BreadcrumbList","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lazyadmin.nl\/"},{"@type":"ListItem","position":2,"name":"35+ PowerShell Commands you Must Know"}]},{"@type":"WebSite","@id":"https:\/\/lazyadmin.nl\/#website","url":"https:\/\/lazyadmin.nl\/","name":"LazyAdmin","description":"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices","publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lazyadmin.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952","name":"Rudy Mens","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","width":500,"height":500,"caption":"Rudy Mens"},"logo":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/"},"description":"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.","sameAs":["https:\/\/lazyadmin.nl","https:\/\/www.facebook.com\/lazyadminnl\/","http:\/\/nl.linkedin.com\/in\/rudymens\/","https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin"]}]}},"uagb_featured_image_src":{"full":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",800,450,false],"thumbnail":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands-150x150.jpg",150,150,true],"medium":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands-300x169.jpg",300,169,true],"medium_large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands-768x432.jpg",768,432,true],"large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",800,450,false],"1536x1536":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",800,450,false],"2048x2048":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",800,450,false],"post-thumb":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",800,450,false],"post-thumb-half":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands-400x225.jpg",400,225,true],"wppr-widget":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands-50x28.jpg",50,28,true],"gform-image-choice-sm":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",300,169,false],"gform-image-choice-md":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",400,225,false],"gform-image-choice-lg":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/09\/top-10-powershell-commands.jpg",600,338,false]},"uagb_author_info":{"display_name":"Rudy Mens","author_link":"https:\/\/lazyadmin.nl\/author\/lajcud8123b\/"},"uagb_comment_info":2,"uagb_excerpt":"PowerShell is a scripting language designed for system administration by Microsoft. These days, PowerShell can be used on multiple platforms and is used to perform or automate a wide range of tasks while using the different PowerShell commands With all ... Read more35+ PowerShell Commands you Must Know","_links":{"self":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/7119"}],"collection":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/comments?post=7119"}],"version-history":[{"count":0,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/7119\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media\/7142"}],"wp:attachment":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media?parent=7119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/categories?post=7119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/tags?post=7119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}