{"id":299302,"date":"2020-02-26T15:00:30","date_gmt":"2020-02-26T15:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299302"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-26T15:00:30","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299302","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c PowerShell \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 REST API"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/veeam\/blog\/490022\/\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u0432\u0430\u0441 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f REST API. \u0410 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0441\u043b\u043e\u0438 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 PowerShell, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 REST API?<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u0410\u0434\u0430\u043c\u0430 \u0411\u0435\u0440\u0442\u0440\u0430\u043c\u0430, \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0430\u0432\u0442\u043e\u0440\u0430 \u0441\u0430\u0439\u0442\u0430 <a href=\"https:\/\/adamtheautomator.com\/\">adamtheautomator.com<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cv\/f8\/oh\/cvf8ohe9fwocpf9kg4sc2r4ejls.jpeg\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 API \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c <a href=\"https:\/\/petstore.swagger.io\/\">swagger petstore API<\/a>.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0443, \u043a\u0430\u043a \u0438 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u0432 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430\u0445, \u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0441 Windows PowerShell v5.1 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u043e\u043d \u0435\u0441\u0442\u044c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 v6 \u0438 \u0432\u044b\u0448\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043d\u0430 Mac \u0438\u043b\u0438 \u043d\u0430 Linux \u041e\u0421 \u2014 \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u0447\u043d\u043e (\u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c).<\/p>\n<h3>\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u043f\u0430\u043f\u043a\u0443 \u0438 \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f<\/h3>\n<p>  \u0414\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u0422\u0443\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u043e\u043b\u0435\u043d \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0430 \u043c\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0438:<\/p>\n<ul>\n<li>\u0412 \u0444\u0430\u0439\u043b\u0435 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 PowerShell (<i>.psd1<\/i>) \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u043e\u0432\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435.<\/li>\n<li>\u0412 \u0444\u0430\u0439\u043b\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044f PowerShell (<i>.psm1<\/i>) \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442\u044b.<\/li>\n<li>\u041d\u0443 \u0438 \u043f\u0430\u043f\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u0430.<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <i>PetStore<\/i> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <i>Source<\/i> \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 <i>C:<\/i><\/p>\n<pre><code class=\"powershell\">New-Item -Type Directory -Path C:\\Source\\PetStore\\ <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u2014 \u044d\u0442\u043e \u0444\u0430\u0439\u043b <i>.psd1<\/i> \u0441 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0433\u0434\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043c\u043e\u0434\u0443\u043b\u044e \u0438 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0451\u043c. \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442\u0430 <b>New-ModuleManifest<\/b>. \u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439, \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <i>Petstore.psd1<\/i> \u0432 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0432\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 C:<\/p>\n<pre><code class=\"powershell\"># Use splatting technique to make it more readable # \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u043a\u043e\u0434\u0443 \u0434\u043b\u044f \u043f\u0443\u0449\u0435\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438   $ModuleManifestParams = @{  \tPath        \t= &quot;C:\\Source\\PetStore\\PetStore.psd1&quot;  # Notice that the psd1 file has the same name as the folder it resides in # \u0424\u0430\u0439\u043b \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0438\u043c\u044f, \u0447\u0442\u043e \u0438 \u043f\u0430\u043f\u043a\u0430   \tGuid        \t= [GUID]::NewGuid().Guid  # A unique GUID for the module for identification # GUID \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f   \tAuthor      \t= &quot;Your Name Here&quot;  # Optional - \u043a\u0442\u043e \u0430\u0432\u0442\u043e\u0440 (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e)       CompanyName \t= &quot;Company Name here&quot;  # Optional - \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e)   \tModuleVersion   = &quot;0.0.1&quot;  # Semantic versioning as recommended best practice for PowerShell modules # \u041f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u0430\u043a \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432 \u043b\u0443\u0447\u0448\u0438\u0445 \u0434\u043e\u043c\u0430\u0445 (\u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442.\u0435. \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443)   \tDescription \t= &quot;A PowerShell module to interact with the HttpBin API&quot;  # A short description of what the module does # \u041a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0448\u0435\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u043c\u043e\u0434\u0443\u043b\u044c  }    # Run New-ModuleManifest with the splatted parameters  # \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430   New-ModuleManifest @ModuleManifestParams <\/code><\/pre>\n<p>  \u0424\u0430\u0439\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <i>.psm1<\/i> \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412 \u043b\u044e\u0431\u043e\u043c PowerShell-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0435\u0433\u043e \u043d\u0430 \u0434\u0438\u0441\u043a <i>C<\/i>.<\/p>\n<h3>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c URI \u0434\u043b\u044f API-\u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u043e\u0432<\/h3>\n<p>  \u0421\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 <i>.psm1<\/i> \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (base URI) \u0434\u043b\u044f API-\u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u043e\u0432 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u2014 \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c (\u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438). \u041d\u0443 \u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JSON.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"powershell\">$script:PetStoreBaseUri = &quot;https:\/\/petstore.swagger.io\/v2&quot;  $script:PetstoreInvokeParams = @{  \tContentType = &quot;application\/json&quot;  } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c<br \/>  <b>Invoke-RestMethod<\/b>:<\/p>\n<pre><code class=\"powershell\">PS51&gt; Invoke-RestMethod -Uri &quot;$script:PetStoreBaseUri\/pet\/&lt;petid&gt;&quot; @script:PetstoreInvokeParams <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442 \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0430 <a href=\"https:\/\/petstore.swagger.io\/v2\/pet\/123\">https:\/\/petstore.swagger.io\/v2\/pet\/<\/a> \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0438\u0442\u043e\u043c\u0446\u0430\u0445. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0435 <b>Get-PetstorePet<\/b>:<\/p>\n<pre><code class=\"powershell\">Function Get-PetstorePet {  \t[cmdletbinding()]  \tparam(      \t[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]      \t[int64]$PetID  \t)  \tBegin {      \t# Using the module-scoped API endpoint URI to create a function-specific URL to query \t# \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448 URI, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 URL, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b       \t$Uri = &quot;$script:PetStoreBaseUri\/pet\/{petId}&quot;  \t}  \tProcess {      \t# Create a temporary variable from the Uri variable  \t# \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 URI  contain int the PetId parameter      \t$TempUri = $Uri -replace &quot;\\{petId\\}&quot;, $PetId          \t      \t# Call the API endpoint using the $TempUri \t# \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a API-\u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0443       \tInvoke-RestMethod -Uri $TempUri -Method Get @script:PetStoreInvokeParams  \t}  }  <\/code><\/pre>\n<p>  \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>PetId<\/b> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 REST API \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0430. <\/p>\n<p>  <i>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/i> \u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/petstore.swagger.io\/#\/pet\/getPetById\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <b>ValueFromPipeline<\/b> \u0438 <b>ValueFromPipelineByPropertyName<\/b> \u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430:<\/p>\n<pre><code class=\"powershell\"># Define pet id's to fetch  # \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0438\u0442\u043e\u043c\u0446\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b   $PetIds = @(100,101,102,103)  $PetIds | Get-PetstorePet <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c<\/h3>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <b>Import-Module<\/b>:<\/p>\n<pre><code class=\"powershell\">PS51&gt; Import-Module C:\\Source\\Petstore <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <b>Get-PetstorePet<\/b>:<\/p>\n<pre><code class=\"powershell\">PS51&gt; Get-PetstorePet -PetId 123 <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c<\/h3>\n<p>  \u041a\u0430\u043a \u0440\u0430\u0437\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432 <a href=\"https:\/\/petstore.swagger.io\/#\/pet\/addPet\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u043b\u044f API<\/a>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0438\u0442\u043e\u043c\u0446\u0430, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u041d\u0443 \u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0438\u0442\u043e\u043c\u0446\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <b>Add-PetstorePet<\/b>.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 PowerShell \u0443\u043c\u0435\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0451 \u0432 \u043a\u0443\u0447\u0443, \u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432 JSON:<\/p>\n<pre><code class=\"powershell\">$BodyJson = @{  \tid    \t= $PetId  \tcategory  = @{      \tid   = $CategoryId      \tname = $CategoryName  \t}  \tname  \t= $PetName  \tphotoUrls = $PhotoUrls  \ttags  \t= $Tags  \tstatus\t= $Status  } | ConvertTo-Json <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043a\u0443\u0434\u0430 \u043f\u0440\u043e\u0449\u0435 \u0438 \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u043e\u0431\u044a\u0435\u043c\u043b\u044e\u0449\u0438\u0439 JSON. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0448\u0435\u0439 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430\u043c \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"powershell\">param(          \t# Id of the pet that you'll create \t\t# ID \u043f\u0438\u0442\u043e\u043c\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]            \t[Alias(&quot;Id&quot;)]  # This is an alias so that we can use it with pipeline properly by piping output from other Functions in this module # \u042d\u0442\u043e \u0430\u043b\u0438\u0430\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435, \u0437\u0430\u0431\u0438\u0440\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0443 \u0432\u0441\u044f\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435       \t[int64]$PetId,            \t# Category ID of the pet to create \t\t# ID \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0438\u0442\u043e\u043c\u0435\u0446      \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[int64]$CategoryId,        \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string]$CategoryName,            \t# Name of the pet \t\t# \u0418\u043c\u044f \u043f\u0438\u0442\u043e\u043c\u0446\u0430       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string]$PetName,            \t# Urls to photos of the pet \t\t# URLs \u0434\u043b\u044f \u0444\u043e\u0442\u043e \u043f\u0438\u0442\u043e\u043c\u0446\u0430       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string[]]$PhotoUrls,            \t# Objects with tags containing Id and Name properties \t\t# \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0441 \u0442\u044d\u0433\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 ID \u0438 Name       \t[Parameter(ValueFromPipelineByPropertyName)]      \t[PSCustomObject[]]$Tags,            \t# Status of the pet &quot;Available&quot;,&quot;Taken&quot; etc. \t\t# \u0421\u0442\u0430\u0442\u0443\u0441 \u043f\u0438\u0442\u043e\u043c\u0446\u0430 (\u0414\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u041f\u0440\u0438\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u043f\u0440.)      \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string]$Status    \t) <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043b\u043e\u043a <b>Begin<\/b> \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0441\u043b\u0435\u0433\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0432 URI (\u0442.\u043a. \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>PetID<\/b> \u0442\u0443\u0442 \u0443\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d):<\/p>\n<pre><code class=\"powershell\">Begin {  \t$Uri = &quot;$script:PetStoreBaseUri\/pet&quot;  } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0431\u043b\u043e\u043a <b>Process<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 post-\u0437\u0430\u043f\u0440\u043e\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u043e\u0440\u043c\u0430\u0442 JSON, \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u043a REST API-\u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0443, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044f <b>Invoke-RestMethod<\/b>.<\/p>\n<pre><code class=\"powershell\">Process {  \t# Create the JSON that we'll post to the endpoint         # \u0421\u043e\u0437\u0434\u0430\u0435\u043c JSON \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 post-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442   \t$BodyObject = @{      \tid    \t= $PetId      \tcategory  = $Category      \tname  \t= $PetName      \tphotoUrls = $PhotoUrls      \ttags  \t= $Tags      \tstatus\t= $Status  \t}              \t  \t# This will remove properties with a null value since it may mess around with some API's \t# \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e null, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u0438   \t$BodyObject.psobject.properties | ? {$_.Value -eq $Null} | Foreach {      \t$BodyObject.psobject.properties.Remove($_.Name)  \t}    \t$BodyJson = $BodyObject | ConvertTo-Json    \t# Call the API endpoint using the $TempUri \t# \u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f $TempUri   \tInvoke-RestMethod -Uri $Script:Uri -Method POST -Body $BodyJson @PetStoreInvokeParams  } <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0443 <b>$BodyObject<\/b> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <i>null<\/i> \u2014 \u0438\u0431\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 REST API \u043d\u0435 \u043b\u044e\u0431\u044f\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u043c\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u0442\u043e\u043c\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 \u0438\u0442\u043e\u0433\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"powershell\">Function Add-PetstorePet {  \t[cmdletbinding()]  \tparam(                   # Id of the pet that you'll create          # ID \u043f\u0438\u0442\u043e\u043c\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]       \t[Alias(&quot;Id&quot;)]          # This is an alias so that we can use it with pipeline properly by piping output from other Functions in this module        # \u042d\u0442\u043e \u0430\u043b\u0438\u0430\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435, \u0437\u0430\u0431\u0438\u0440\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0443 \u0432\u0441\u044f\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435       \t[int64]$PetId,         \t# hash containing Id and name of category         # \u0418\u043c\u044f \u0438 ID \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0438\u0442\u043e\u043c\u0435\u0446, \u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438       \t[Parameter(ValueFromPipelineByPropertyName)]      \t[hashtable]$Category,            # Name of the pet          # \u0418\u043c\u044f \u043f\u0438\u0442\u043e\u043c\u0446\u0430       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string]$PetName,           # Urls to photos of the pet         # URLs \u0434\u043b\u044f \u0444\u043e\u0442\u043e \u043f\u0438\u0442\u043e\u043c\u0446\u0430       \t[Parameter(Mandatory, ValueFromPipelineByPropertyName)]      \t[string[]]$PhotoUrls,            # Objects with tags containing Id and Name properties          # \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0441 \u0442\u044d\u0433\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 ID \u0438 Name       \t[Parameter(ValueFromPipelineByPropertyName)]      \t[PSCustomObject[]]$Tags,            # Status of the pet &quot;Available&quot;,&quot;Taken&quot; etc.          # \u0421\u0442\u0430\u0442\u0443\u0441 \u043f\u0438\u0442\u043e\u043c\u0446\u0430 (\u0414\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u041f\u0440\u0438\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u043f\u0440.)       \t[Parameter(ValueFromPipelineByPropertyName)]      \t[string]$Status    \t)  \tBegin {      \t$Uri = &quot;$script:PetStoreBaseUri\/pet&quot;  \t}  \tProcess {      \t# Create the JSON that we'll post to the endpoint         # \u0421\u043e\u0437\u0434\u0430\u0435\u043c JSON \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 post-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442        \t$BodyObject = @{          \tid    \t= $PetId          \tcategory  = $Category          \tname  \t= $PetName          \tphotoUrls = $PhotoUrls          \ttags  \t= $Tags          \tstatus\t= $Status      \t}        \t$BodyObject.psobject.properties | ? {$_.Value -eq $Null} | Foreach {          \t$BodyObject.psobject.properties.Remove($_.Name)      \t}        \t$BodyJson = $BodyObject | ConvertTo-Json        \t# Call the API endpoint using the $TempUri         # \u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f $TempUri              \t Invoke-RestMethod -Uri $Uri -Method POST -Body $BodyJson @script:PetStoreInvokeParams    \t}  } <\/code><\/pre>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"powershell\">PS51&gt; Import-Module C:\\Source\\Petstore -Force  PS51&gt; Add-PetstorePet -PetName Fido -PetId 1 -PhotoUrls &quot;http:\/\/somesite.com\/picture.jpg&quot;  PS51&gt; Get-PetstorePet -PetId 1 <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043e\u0441\u0432\u043e\u0438\u043b\u0438\u0441\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u043e\u0436\u0435\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 REST API.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <b>Add-PetstorePet<\/b> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f <b>Remove-PetstorePet<\/b> \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0434\u0430\u0442\u044c \u0435\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <b>Invoke-RestMethod<\/b>, \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 <code>DELETE<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"powershell\">Function Remove-PetstorePet {      [cmdletbinding()]  \tparam(      \t[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]      \t[Alias(&quot;Id&quot;)]      \t[int64]$PetId  \t)  \tBegin {      \t$Uri = &quot;$script:PetStoreBaseUri\/pet\/{petId}&quot;  \t}  \tProcess {     \t # Create a temporary variable from the Uri variable containing the PetId parameter          # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 URI       \t$TempUri = $Uri -replace &quot;\\{petId\\}&quot;, $PetId      \t      \t# Call the API endpoint using the $TempUri         # \u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f $TempUri               \tInvoke-RestMethod -Uri $TempUri -Method DELETE @script:PetStoreInvokeParams           # NOTICE how we replaced GET with DELETE         # \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u0442\u0443\u0442 GET \u043d\u0430 DELETE    \t}  } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u044b\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043d\u0430 \u043f\u0440\u0438\u0435\u043c <a href=\"https:\/\/adamtheautomator.com\/the-powershell-parameter\/#pipeline-input\">pipeline input<\/a>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0439\u043f \u043f\u0438\u0442\u043e\u043c\u0446\u0435\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <b>Remove-PetstorePet<\/b>:<\/p>\n<pre><code class=\"powershell\">PS51&gt; Get-PetstorePet -PetId 1 | Remove-PetstorePet <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f PowerShell \u0434\u043b\u044f REST API \u043c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043e \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043d\u043e\u0433\u0438\u0435 REST API \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u0445\u043e\u0436\u0438 \u0441 swagger API, \u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 API. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0436\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  \u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c \u0447\u0435\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438\u0437 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p><\/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\/company\/veeam\/blog\/490022\/\"> https:\/\/habr.com\/ru\/company\/veeam\/blog\/490022\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/veeam\/blog\/490022\/\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u0432\u0430\u0441 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f REST API. \u0410 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0441\u043b\u043e\u0438 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 PowerShell, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 REST API?<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u0410\u0434\u0430\u043c\u0430 \u0411\u0435\u0440\u0442\u0440\u0430\u043c\u0430, \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0430\u0432\u0442\u043e\u0440\u0430 \u0441\u0430\u0439\u0442\u0430 <a href=\"https:\/\/adamtheautomator.com\/\">adamtheautomator.com<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cv\/f8\/oh\/cvf8ohe9fwocpf9kg4sc2r4ejls.jpeg\">  <\/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-299302","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299302","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=299302"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299302\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}