{"id":302578,"date":"2020-04-27T15:00:17","date_gmt":"2020-04-27T15:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=302578"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=302578","title":{"rendered":"PowerShell for beginners"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/499312\/\">\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 PowerShell \u043f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u043c \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b (Cmdlet).<br \/>  \u0412\u044b\u0437\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Verb-Noun -Parameter1 ValueType1 -Parameter2 ValueType2[] <\/code><\/pre>\n<p>  <\/p>\n<h3>Help<\/h3>\n<p>  <\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 PowerShell \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b Get-Help. \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432: example, detailed, full, online, showWindow.<br \/>  Get-Help Get-Service -full \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b Get-Service<br \/>  Get-Help Get-S* \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 Get-S*<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 Microsoft \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 Get-Evenlog<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p6\/77\/o3\/p677o3zxcak6cv_9l8iv70e0dyy.png\" alt=\"image\"><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 [], \u0442\u043e \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0430\u043c\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <a name=\"habracut\"><\/a>\u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u0441\u043a\u043e\u0431\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435, \u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 EntryType, \u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. <\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0438\u0436\u0435 \u0432 \u043f\u043e\u043b\u0435 Required. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 After \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 Required \u0441\u0442\u043e\u0438\u0442 false. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u043e\u043b\u0435 Position \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e Named. \u042d\u0442\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0442\u043e \u0435\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Get-EventLog -LogName Application -After 2020.04.26<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 LogName \u0432\u043c\u0435\u0441\u0442\u043e Named \u0431\u044b\u043b\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0447\u0438\u0441\u043b\u043e 0 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u0431\u0435\u0437 \u0438\u043c\u0435\u043d\u0438, \u0430 \u0443\u043a\u0430\u0437\u0430\u0432 \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Get-EventLog Application -After 2020.04.26<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Get-EventLog -Newest 5 Application<\/code><\/pre>\n<p>  <\/p>\n<h3>Alias<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432 PowerShell \u0435\u0441\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b (Alias). <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u0430 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b Set-Location \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f cd. <\/p>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<p>   <\/p>\n<pre><code class=\"powershell\">Set-Location \u201cD:\\\u201d<\/code><\/pre>\n<p>  <\/p>\n<p>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">cd \u201cD:\\\u201d<\/code><\/pre>\n<p>  <\/p>\n<h3>History <\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Get-History<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0437 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 Invoke-History 1; Invoke-History 2<\/p>\n<p>  <\/p>\n<p>\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e Clear-History<\/p>\n<p>  <\/p>\n<h3>Pipeline<\/h3>\n<p>  <\/p>\n<p>\u041f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432 powershell \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0442\u043e\u0440\u0443\u044e. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Get-Verb | Measure-Object<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043f\u0440\u043e\u0449\u0435. \u0415\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Get-Verb &quot;get&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u043f\u0440\u0430\u0432\u043a\u0443 Get-Help Get-Verb -Full, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Verb \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 pipline input \u0438 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e ByValue.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dz\/wd\/f4\/dzwdf4bow0jhwkg1j0vqvq8rwcw.png\" alt=\"image\"><\/p>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c Get-Verb \u00abget\u00bb \u043d\u0430 \u00abget\u00bb | Get-Verb.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Verb \u043a\u043e\u043c\u0430\u043d\u0434\u044b Get-Verb \u0447\u0435\u0440\u0435\u0437 pipline input \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e.<br \/>  \u0422\u0430\u043a\u0436\u0435 pipline input \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c ByPropertyName. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0441\u043e \u0441\u0445\u043e\u0436\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Verb.<\/p>\n<p>  <\/p>\n<h3>Variables<\/h3>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0430 $ \u0432\u043f\u0435\u0440\u0435\u0434\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$example = 4<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0438\u043c\u0432\u043e\u043b &gt; \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 <br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, $example &gt; File.txt <br \/>  \u042d\u0442\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $example \u0432 \u0444\u0430\u0439\u043b<br \/>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 Set-Content -Value $example -Path File.txt<\/p>\n<p>  <\/p>\n<h3>Arrays<\/h3>\n<p>  <\/p>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = @(\u201cFirst\u201d, \u201cSecond\u201d)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = @()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample[0]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample += \u201cThird\u201d<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample += @(\u201cFourth\u201d, \u201cFifth\u201d)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample | Sort<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample | Sort -Descending<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u0441\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0418 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0431\u044b\u043b\u0438 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = $ArrayExample | Sort<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 PowerShell \u043d\u0435\u0442, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = $ArrayExample | where { $_ -ne \u201cFirst\u201d }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = $ArrayExample | where { $_ -ne $ArrayExample[0] } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">$ArrayExample = $null<\/code><\/pre>\n<p>  <\/p>\n<h3>Loops<\/h3>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0446\u0438\u043a\u043b\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">for($i = 0; $i -lt 5; $i++){} <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$i = 0 while($i -lt 5){} <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$i = 0 do{} while($i -lt 5) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">$i = 0 do{} until($i -lt 5) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">ForEach($item in $items){}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 break.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 continue.<\/p>\n<p>  <\/p>\n<h3>Conditional Statements<\/h3>\n<p>  <\/p>\n<pre><code class=\"powershell\">if () {} elseif () {} else<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">switch($someIntValue){   1 { \u201cOption 1\u201d }   2 { \u201cOption 2\u201d }   default { \u201cNot set\u201d } } <\/code><\/pre>\n<p>  <\/p>\n<h3>Function<\/h3>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">function Example () {   echo &amp;args }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Example \u201cFirst argument\u201d \u201cSecond argument\u201d<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">function Example () {   param($first, $second) } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"powershell\">function Example ($first, $second) {}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Example -first \u201cFirst argument\u201d -second \u201cSecond argument\u201d<\/code><\/pre>\n<p>  <\/p>\n<h3>Exception<\/h3>\n<p>  <\/p>\n<pre><code class=\"powershell\">try{ } catch [System.Net.WebException],[System.IO.IOException]{ } catch { } finally{ } <\/code><\/pre>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/499312\/\"> https:\/\/habr.com\/ru\/post\/499312\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/499312\/\">\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 PowerShell \u043f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u043c \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b (Cmdlet).<br \/>  \u0412\u044b\u0437\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"powershell\">Verb-Noun -Parameter1 ValueType1 -Parameter2 ValueType2[] <\/code><\/pre>\n<p>  <\/p>\n<h3>Help<\/h3>\n<p>  <\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 PowerShell \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b Get-Help. \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432: example, detailed, full, online, showWindow.<br \/>  Get-Help Get-Service -full \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b Get-Service<br \/>  Get-Help Get-S* \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 Get-S*<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 Microsoft \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 Get-Evenlog<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p6\/77\/o3\/p677o3zxcak6cv_9l8iv70e0dyy.png\" alt=\"image\"><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 [], \u0442\u043e \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0430\u043c\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-302578","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302578"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302578\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}