{"id":1599,"date":"2019-08-26T23:06:25","date_gmt":"2019-08-27T06:06:25","guid":{"rendered":"https:\/\/doubleecpu.com\/?page_id=1599"},"modified":"2019-08-30T15:49:39","modified_gmt":"2019-08-30T22:49:39","slug":"powershell","status":"publish","type":"page","link":"https:\/\/doubleecpu.com\/index.php\/microsoft\/power-shell-scripting\/powershell\/","title":{"rendered":"PowerShell"},"content":{"rendered":"\n<p>PowerShell is a Object Oriented command line shell and scripting language  that is used for task automation and configuration management, which is built on the .Net and .Net Core.  <br>PowerShell can interact with any Windows created software, sites, lists.<br>Some software configuration can only be accessed through PowerShell<br>Documantation for PowerShell:  <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/scripting\/overview?view=powershell-6\">docs.microsoft.com<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">cmdlet<\/h2>\n\n\n\n<p>cmdlet (&#8220;command-let&#8221;) is a specialized .Net class that implements a specific task or operation and will have required and optional parameters.<br>Naming convention used to construct a cmdlet follows a verb-noun object name. Verbs are action oriented words, such as Add, Get, Set, Update;  Nouns describe what will be acted on such as Get-Azure(Azure Cloud Service), New-ADUser (Active Directory User),  Get-SPUser (Sharepoint User). The Nouns may represent core module objects and verbs may invoke methods\/commands that were developed to be run as cmdlets. Example Microsoft.Sharepoint.PowerShell.dll includes over 800 commands.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Important cmdlets:<\/h2>\n\n\n\n<p><strong>get-Command<\/strong> this will display all the cmdlets that are available in the current PowerShell Session. This can be filter using get-Command -noun [name]   ([name] can use *wilcard* for searching  and matching nouns)<br><br><strong>get-Help<\/strong> displays help information for any cmdlet and can be set for 3 levels of details: Normal, Detailed, and Full<br><br><strong>get-Member<\/strong> displays a list of all the methods and properties that are associated with any cmdlets using piplines<br><br><strong>where-Object<\/strong> creates a filtered list of the objects where objects matches the criteria parameter<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">pipeline<\/h2>\n\n\n\n<p>The concept of passing of a result of a command to another command. <br>command-x | command-y |command-z <br>same as (command-z (command-y (command-x)))<br>Example get-Service | where-Object {$_.DisplayName -like &#8220;Sharep*&#8221;} <br>Returns objects where DisplayName starts with Sharep<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">parameter set<\/h2>\n\n\n\n<p>parameter sets are different ways to run a certain command which are mutually exclusive and can&#8217;t be combined. Listed in the get-Help result Syntax. This will list parameters can be run at the same time and list separate grouping called syntax for mutually exclusive parameter sets.   <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Variables<\/h2>\n\n\n\n<p>To create an Object variable in PowerShell use the $[object_name] <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FolderBrowserDialog<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">PS C:\\&gt; $NanoFolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog\nPS C:\\&gt; $NanoFolderBrowser <\/pre>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/doubleecpu.com\/wp-content\/uploads\/2019\/08\/PS_FolderBrowserDialog-1.png\" alt=\"ShowNewFolderButton : True\nSelectedPath        : C:\\Nano\nRootFolder          : Desktop\nDescription         : \nTag                 : \nSite                : \nContainer           : \" class=\"wp-image-1602\" width=\"542\" height=\"67\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">OpenFileDialog<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">$FileBrowser = New-Object <code>\nSystem.Windows.Forms.OpenFileDialog<\/code>\n-Property @{ \n  Title = \"Select Windows Server image\"\n  InitialDirectory = [Environment]::GetFolderPath('MyComputer') \n  MultiSelect = 'false'\n  }<\/pre>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/doubleecpu.com\/wp-content\/uploads\/2019\/08\/PS_FolderBrowserDialog.png\" alt=\"CheckFileExists              : True\nMultiselect                  : True\nReadOnlyChecked              : False\nShowReadOnly                 : False\nSafeFileName                 : Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO\nSafeFileNames                : {Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO}\nAddExtension                 : True\nCheckPathExists              : True\nDefaultExt                   : \nDereferenceLinks             : True\nFileName                     : C:\\Users\\pc\\Downloads\\Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO\nFileNames                    : {C:\\Users\\pc\\Downloads\\Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO}\nFilter                       : \nFilterIndex                  : 0\nInitialDirectory             : \nRestoreDirectory             : False\nShowHelp                     : False\nSupportMultiDottedExtensions : False\nTitle                        : Select Folder for VHDX\nValidateNames                : True\nCustomPlaces                 : {}\nAutoUpgradeEnabled           : True\nTag                          : \nSite                         : \nContainer                    : \" class=\"wp-image-1601\" width=\"535\" height=\"215\"\/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell is a Object Oriented command line shell and scripting language that is used for task automation and configuration management, which is built on the .Net and .Net Core. PowerShell can interact with any Windows created software, sites, lists.Some software configuration can only be accessed through PowerShellDocumantation for PowerShell: docs.microsoft.com cmdlet cmdlet (&#8220;command-let&#8221;) is a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/doubleecpu.com\/index.php\/microsoft\/power-shell-scripting\/powershell\/\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;PowerShell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1613,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1599","page","type-page","status-publish","hentry"],"featured_media_urls":[],"_links":{"self":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/1599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1599"}],"version-history":[{"count":0,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/1599\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/1613"}],"wp:attachment":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}