{"id":131,"date":"2021-10-14T14:35:17","date_gmt":"2021-10-14T14:35:17","guid":{"rendered":"https:\/\/ouritsource.com\/blog\/?p=131"},"modified":"2021-10-15T17:25:34","modified_gmt":"2021-10-15T17:25:34","slug":"powershell-cheat-sheet","status":"publish","type":"post","link":"https:\/\/ouritsource.com\/blog\/powershell-cheat-sheet\/","title":{"rendered":"PowerShell Cheat Sheet"},"content":{"rendered":"<body>\n<figure id=\"tablepress-powershellcommands-no-2\" class=\"wp-block-table\"><table class=\"table\"><thead><tr><th>Command name<\/th><th>Alias<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>Set-Location<\/td><td>cd, chdir, sl<\/td><td>Sets the current working location to a specified location.<\/td><\/tr><tr><td>Get-Content<\/td><td>cat, gc, type<\/td><td>Gets the content of the item at the specified location.<\/td><\/tr><tr><td>Add-Content<\/td><td>ac<\/td><td>Adds content to the specified items, such as adding words to a file.<\/td><\/tr><tr><td>Set-Content<\/td><td>sc<\/td><td>Writes or replaces the content in an item with new content.<\/td><\/tr><tr><td>Copy-Item<\/td><td>copy, cp, cpi<\/td><td>Copies an item from one location to another.<\/td><\/tr><tr><td>Remove-Item<\/td><td>del, erase, rd, ri, rm, rmdir<\/td><td>Deletes the specified items.<\/td><\/tr><tr><td>Move-Item<\/td><td>mi, move, mv<\/td><td>Moves an item from one location to another.<\/td><\/tr><tr><td>Set-Item<\/td><td>si<\/td><td>Changes the value of an item to the value specified in the command.<\/td><\/tr><tr><td>New-Item<\/td><td>ni<\/td><td>Creates a new item.<\/td><\/tr><tr><td>Start-Job<\/td><td>sajb<\/td><td>Starts a Windows PowerShell background job.<\/td><\/tr><tr><td>Compare-Object<\/td><td>compare, dif<\/td><td>Compares two sets of objects.<\/td><\/tr><tr><td>Group-Object<\/td><td>group<\/td><td>Groups objects that contain the same value for specified properties.<\/td><\/tr><tr><td>Invoke-WebRequest<\/td><td>curl, iwr, wget<\/td><td>Gets content from a web page on the Internet.<\/td><\/tr><tr><td>Measure-Object<\/td><td>measure<\/td><td>Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files \u2026<\/td><\/tr><tr><td>Resolve-Path<\/td><td>rvpa<\/td><td>Resolves the wildcard characters in a path, and displays the path contents.<\/td><\/tr><tr><td>Resume-Job<\/td><td>rujb<\/td><td>Restarts a suspended job<\/td><\/tr><tr><td>Set-Variable<\/td><td>set, sv<\/td><td>Sets the value of a variable. Creates the variable if one with the requested name does not exist.<\/td><\/tr><tr><td>Show-Command<\/td><td>shcm<\/td><td>Creates Windows PowerShell commands in a graphical command window.<\/td><\/tr><tr><td>Sort-Object<\/td><td>sort<\/td><td>Sorts objects by property values.<\/td><\/tr><tr><td>Start-Service<\/td><td>sasv<\/td><td>Starts one or more stopped services.<\/td><\/tr><tr><td>Start-Process<\/td><td>saps, start<\/td><td>Starts one or more processes on the local computer.<\/td><\/tr><tr><td>Suspend-Job<\/td><td>sujb<\/td><td>Temporarily stops workflow jobs.<\/td><\/tr><tr><td>Wait-Job<\/td><td>wjb<\/td><td>Suppresses the command prompt until one or all of the Windows PowerShell background jobs running in the session are \u2026<\/td><\/tr><tr><td>Where-Object<\/td><td>?, where<\/td><td>Selects objects from a collection based on their property values.<\/td><\/tr><tr><td>Write-Output<\/td><td>echo, write<\/td><td>Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline,\u2026<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>To run a powershell script from a command line, the powershell script should have a PS1 exrtension such as <em>myscript.ps1. <\/em>Then from the command line, one would enter the <strong>PS <\/strong>command, followed by the file. For example: <strong>PS c:\\users\\me\\desktop\\myscript.ps1<\/strong><\/p>\n\n\n\n<p><strong>Reference:<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Command name Alias Description Set-Location cd, chdir, sl Sets the current working location to a specified location. Get-Content cat, gc, type Gets the content of the item at the specified location. Add-Content&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[19],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-windows-powershell","no-thumbnail"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":3,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions\/134"}],"wp:attachment":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}