{"id":263511,"date":"2015-08-13T17:16:02","date_gmt":"2015-08-13T13:16:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263511"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263511","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Pester \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 PowerShell \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432"},"content":{"rendered":"<p>             <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c1e\/d33\/484\/c1ed3348474f440993d2b57f5c5217ac.png\" align=\"left\"\/>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043d\u0430 PowerShell \u0438 \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445, \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f Pester \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443.<br \/>  <a name=\"habracut\"><\/a><br \/>  Pester \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043a \u043b\u044e\u0431\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0432 powershell \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c, \u043a\u043c\u0434\u043b\u0435\u0442\u0430\u043c, \u043c\u043e\u0434\u0443\u043b\u044f\u043c. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0440\u0430\u0437\u0443, \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p>  Pester \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 powershell \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u0441\u0440\u0435\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. Pester \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430_\u0447\u0435\u0440\u0435\u0437_\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u0438 \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0430\u0448\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0418 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u2013 Pester \u0442\u043e\u0436\u0435 \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442.<\/p>\n<h4>\u041a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c.\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Pester \u0441 PowerShell ISE<\/h4>\n<p>  Pester \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f powershell, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 Scott Muc \u0438 <a href=\"https:\/\/github.com\/pester\/Pester\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0439<\/a> \u043d\u0430 Github. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Pester \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u0430\u043f\u043e\u043a Modules \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2d8\/41d\/ed6\/2d841ded68fe485eb4da95ac7d4b8e39.png\"\/><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0427\u0442\u043e \u0437\u0430 \u043f\u0430\u043f\u043a\u0430 Modules?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0430\u043f\u043e\u043a Modules \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0430\u043f\u043a\u0430 Modules \u043f\u043e \u043f\u0443\u0442\u0438 %UserProfile%\\Documents\\WindowsPowerShell\\Modules \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0448\u0435\u0439 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u0440\u0438\u0447\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u043e\u043a\u0430 \u0432\u044b \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435. \u0410 \u0432 \u043f\u0430\u043f\u043a\u0435 %windir%\\system32\\WindowsPowerShell\\v1.0\\Modules \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.<\/p>\n<p>  \u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043f\u043e\u043a \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 powershell \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f $env:PSModulePath. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043f\u043e\u043a Modules \u0441 \u043c\u043e\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430:  <\/p>\n<pre><code>PS C:\\&gt; $env:PSModulePath -split ';' F:\\Users\\sgerasimov\\Documents\\WindowsPowerShell\\Modules C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\  <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Lync Server \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043a \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438.  <\/div>\n<\/div>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043f\u0430\u043f\u043a\u043e\u0439 Modules \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e powershell, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>cd $env:USERPROFILE\\documents new-item -Name WindowsPowerShell -ItemType directory new-item -Path .\\WindowsPowerShell -Name Modules -ItemType directory <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/616\/322\/69a\/61632269a40f415d871887d4d7364075.png\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0439\u0442\u0435 \u0430\u0440\u0445\u0438\u0432 \u0432 \u043f\u0430\u043f\u043a\u0443 Pester \u0432 \u043f\u0430\u043f\u043a\u0435 Modules.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6df\/530\/64e\/6df53064ef274fb29cccf16edc164890.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Pester \u0441 PowerShell ISE \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 %UserProfile%\\Documents\\WindowsPowerShell \u0444\u0430\u0439\u043b Microsoft.PowerShellISE_profile.ps1 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code>try {     Import-Module Pester } catch {     Write-Warning &quot;\u0418\u043c\u043f\u043e\u0440\u0442 \u043c\u043e\u0434\u0443\u043b\u044f Pester \u043d\u0435 \u0443\u0434\u0430\u043b\u0441\u044f&quot; }  <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c PowerShell ISE \u043c\u043e\u0434\u0443\u043b\u044c Pester \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0432\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c.<\/p>\n<h4>\u041a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c? \u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430<\/h4>\n<p>  \u0422\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<p>  \u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0438\u043c\u044f\u0441\u043a\u0440\u0438\u043f\u0442\u0430.Tests.ps1. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 CreateUser.ps1 \u0438\u043b\u0438 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c. \u0422\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0438 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u0432 \u0444\u0430\u0439\u043b CreateUser.Tests.ps1<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442\u044b \u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0445, Pester \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u00ab.Tests.\u00bb \u0432 \u0438\u043c\u0435\u043d\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0438 \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0438\u0437 \u043d\u0438\u0445. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435, \u0430 \u043d\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u0424\u0430\u0439\u043b \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 powershell \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0433\u0440\u0443\u043f\u043f \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 Describe \u0438 Context. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 It \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 1 \u0442\u0435\u0441\u0442.<\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Pester \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b.<\/p>\n<h5><i>\u041f\u0440\u0438\u043c\u0435\u0440<\/i><\/h5>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u201cHello World!\u201d \u0438 \u0432\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0442\u0435\u0441\u0442.<\/p>\n<p>  \u0424\u0430\u0439\u043b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 HelloWorld.ps1 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c:  <\/p>\n<pre><code>return &quot;Hello world!&quot; <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c HelloWorld.Tests.ps1. \u0412 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u201cHello world!\u201d:  <\/p>\n<pre><code>Describe &quot;\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 HelloWorld&quot; {        it &quot;\u0421\u043a\u0440\u0438\u043f\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 Hello World!&quot; {      $result = .\\HelloWorld.ps1     $result | Should Be &quot;Hello World!&quot;     } } <\/code><\/pre>\n<p>  \u0411\u043b\u043e\u043a Describe \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u0446\u0435\u043b\u043e\u043c \u043a\u0430\u043a\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430 \u0432 \u0431\u043b\u043e\u043a\u0435 It \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0430\u043c \u0442\u0435\u0441\u0442. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0439  <\/p>\n<pre><code>$result = .\\HelloWorld.ps1 <\/code><\/pre>\n<p>\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u043e\u0439  <\/p>\n<pre><code>$result | Should Be &quot;Hello World!&quot; <\/code><\/pre>\n<p>\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <b>Should<\/b> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e. \u0410 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c <b>Be<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2014 \u044d\u0442\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a\u0435 \u00abHello World!\u00bb.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0437\u0430\u0434\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <b>Should<\/b> \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d, \u0432 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0435\u0441\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u043b\u0435\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043a\u043e\u0434, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0432 \u0444\u0430\u0439\u043b HelloWorld.Tests.ps1 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b HelloWorld.ps1 \u0438 HelloWorld.Tests.ps1. \u0423 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u201cF:\\Projects\\iLearnPester\\Examples&gt;\u201d \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <u>Invoke-Pester<\/u> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5e9\/711\/f47\/5e9711f478184441b5c443fafa859497.png\"\/><\/p>\n<p>  \u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0448\u0435\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0441\u0442\u0430 (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0440\u0430\u0437\u0435 \u043f\u043e\u0441\u043b\u0435 \u0431\u043b\u043e\u043a\u0430 It). \u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u0435\u0439, \u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0441\u0442\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u043d\u044b\u043c, \u0430 \u043d\u0438\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ab8\/d14\/203\/ab8d14203e724855ab29c620ebc39e86.png\"\/><\/p>\n<p>  \u041e\u0436\u0438\u0434\u0430\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u00abHello World!\u00bb, \u043d\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0435\u0440\u043d\u0443\u043b \u0441\u0442\u0440\u043e\u043a\u0443 \u00abHello all!\u00bb. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0441\u0442\u0440\u043e\u043a\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442.<\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430_\u0447\u0435\u0440\u0435\u0437_\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>. \u0422\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0438\u0448\u0435\u0442\u0435 \u0442\u0435\u0441\u0442, \u0430 \u0443\u0436 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\/\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u043d\u0435\u043c\u0443.<\/p><\/blockquote>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <b>Should<\/b> \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430 \u043d\u0435\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <b>Be<\/b>) \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435. \u0412 Pester \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f:  <\/p>\n<ul>\n<li>Should Be<\/li>\n<li>Should BeExactly<\/li>\n<li>Should Exist<\/li>\n<li>Should Contain<\/li>\n<li>Should ContainExactly<\/li>\n<li>Should Match<\/li>\n<li>Should MatchExactly<\/li>\n<li>Should Throw<\/li>\n<li>Should BeNullOrEmpty<\/li>\n<\/ul>\n<p>  \u0412\u043d\u0443\u0442\u0440\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c Not \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: Should Not Be, Should Not Exist.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<h5><i>Should Be<\/i><\/h5>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0435 \u0440\u0430\u0432\u043d\u044b. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u0447\u0438\u0441\u043b\u0430, \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b \u0438 \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (pscustomobject) \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f.<\/p>\n<pre><code>#\u0441\u0442\u0440\u043e\u043a\u0438  $a = &quot;\u0441\u0442\u0440\u043e\u043a\u0430&quot; $a | Should Be &quot;\u0441\u0442\u0440\u043e\u043a\u0430&quot;         \t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $a | Should Be &quot;\u0421\u0422\u0420\u041e\u041a\u0410&quot;         \t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $a | Should Be &quot;\u0414\u0440\u0443\u0433\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430&quot;\t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e $a | Should Not Be &quot;\u0414\u0440\u0443\u0433\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430&quot;\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  #\u0447\u0438\u0441\u043b\u0430  $a = 10 $a | Should Be 10         \t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $a | Should Be 2          \t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e $a | Should Not 2         \t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  #\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b $a = 1,2,3 $a | Should Be 1,2,3\t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $a | Should Be 1,2,3,4\t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $a | Should Be 4,5,6\t\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e  #\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0442\u0440\u043e\u043a $a = &quot;qwer&quot;,&quot;asdf&quot;,&quot;zxcv&quot; $a | Should Be &quot;qwer&quot;,&quot;asdf&quot;,&quot;ZXCV&quot;\t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  $a | Should Be &quot;qwer&quot;,&quot;asdf&quot;,&quot;zxcv&quot;, &quot;rrr&quot; \t#\u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should BeExtactly<\/i><\/h5>\n<p>  \u0422\u043e \u0436\u0435, \u0447\u0442\u043e \u0438 Should Be, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430<\/p>\n<pre><code>$actual=&quot;Actual value&quot; $actual | Should BeExactly &quot;Actual value&quot; # \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $actual | Should BeExactly &quot;actual value&quot; # \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should Exist<\/i><\/h5>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 PS \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432. \u0421\u0430\u043c\u043e\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u041f\u043e \u0441\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043c\u0434\u043b\u0435\u0442 test-path \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>$actual=(Dir . )[0].FullName Remove-Item $actual $actual | Should Exist # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e  import-module ActiveDirectory $ADObjectFQDN = &quot;AD:CN=Some User,OU=Users,DC=company,DC=com&quot; $ADObjectFQDN |  Should Exist # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0435\u0441\u0442\u044c  $registryKey = &quot;HKCU:\\Software\\Microsoft\\Driver Signing&quot; $registryKey | Should Exist # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u0435\u0442\u043a\u0430 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0435\u0441\u0442\u044c. <\/code><\/pre>\n<p>  \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u0435\u0442\u043a\u0438 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u043e \u043d\u0435 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u0442.\u043a. PS \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 \u0440\u0435\u0435\u0441\u0442\u0440\u043e\u043c \u0434\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043b\u044e\u0447\u0430\u043c \u043a\u0430\u043a \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u0432\u0435\u0442\u0432\u0435\u0439 \u0440\u0435\u0435\u0441\u0442\u0440\u0430. \u041e\u043d \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<h5><i>Should Contain<\/i><\/h5>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442. \u041f\u043e\u0438\u0441\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>Set-Content -Path c:\\temp\\file.txt -Value '\u0421\u044a\u0435\u0448\u044c \u0435\u0449\u0435 \u044d\u0442\u0438\u0445 \u043c\u044f\u0433\u043a\u0438\u0445 \u0444\u0440\u0430\u043d\u0446\u0443\u0437\u0441\u043a\u0438\u0445 \u0431\u0443\u043b\u043e\u043a' 'c:\\temp\\file.txt' | Should Contain '\u0421\u044a\u0435\u0448\u044c \u0415\u0449\u0435' # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e 'c:\\temp\\file.txt' | Should Contain '\u0421\u044a\u0435\u0448\u044c*\u0431\u0443\u043b\u043e\u043a' # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should ContainExactly<\/i><\/h5>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442. \u041f\u043e\u0438\u0441\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>Set-Content -Path c:\\temp\\file.txt -Value '\u0421\u044a\u0435\u0448\u044c \u0435\u0449\u0435 \u044d\u0442\u0438\u0445 \u043c\u044f\u0433\u043a\u0438\u0445 \u0444\u0440\u0430\u043d\u0446\u0443\u0437\u0441\u043a\u0438\u0445 \u0431\u0443\u043b\u043e\u043a' 'c:\\temp\\file.txt' | Should Contain '\u0421\u044a\u0435\u0448\u044c \u0415\u0449\u0435' # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e 'c:\\temp\\file.txt' | Should Contain '\u0421\u044a\u0435\u0448\u044c*\u0431\u0443\u043b\u043e\u043a' # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should Match<\/i><\/h5>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<pre><code>&quot;\u0412\u0430\u0441\u044f&quot; | Should Match &quot;.\u0430\u0441\u044f&quot; #  \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e &quot;\u0412\u0430\u0441\u044f&quot; | Should Match ([regex]::Escape(&quot;.\u0430\u0441\u044f&quot;)) #  \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e  <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should MatchExactly<\/i><\/h5>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<pre><code>&quot;\u0412\u0430\u0441\u044f&quot; | Should Match &quot;\u0412\u0410\u0421\u042f&quot; #  \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e &quot;\u0412\u0430\u0441\u044f&quot; | Should Match &quot;.\u0430\u0441\u044f&quot; #  \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should Throw<\/i><\/h5>\n<p>  \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442-\u0431\u043b\u043e\u043a\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442-\u0431\u043b\u043e\u043a. \u0421 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<pre><code>{ \u043d\u0435\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f\u0444\u0443\u043d\u043a\u0446\u0438\u044f } | Should Throw # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  { throw &quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432&quot; } | Should Throw &quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432&quot; # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  { throw &quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432&quot; } | Should Throw &quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432&quot; # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e  {throw &quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432&quot;} | Should Throw &quot;\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432&quot; # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e   { $foo = 1 } | Should Not Throw # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h5><i>Should BeNullOrEmpty<\/i><\/h5>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e $null \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u043e (\u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438, \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u0442.\u043f.). \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e $null \u044d\u0442\u043e \u043d\u0435 0.<\/p>\n<pre><code>$a = $null $b = 0 $c = [string]&quot;&quot; $d = @()  $a | Should BeNullOrEmpty  # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $b | Should BeNullOrEmpty  # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e $c | Should BeNullOrEmpty  # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e $d | Should BeNullOrEmpty  # \u041f\u0440\u043e\u0439\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u0427\u0442\u043e \u043e\u043d \u0435\u0449\u0435 \u0443\u043c\u0435\u0435\u0442?<\/h4>\n<p>  <\/p>\n<h5><i>Mock-\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/i><\/h5>\n<p>  \u0412 Pester \u0435\u0441\u0442\u044c mock-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0442\u0435\u0441\u0442\u0430 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043a\u043c\u0434\u043b\u0435\u0442.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c ip-\u0430\u0434\u0440\u0435\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u043a \u043a\u0430\u043a\u043e\u0439 \u0441\u0435\u0442\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 dns-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041d\u043e \u0443 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0441\u0435\u0433\u043e 1 ip \u0430\u0434\u0440\u0435\u0441 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0445\u043b\u043e\u043f\u043e\u0442\u043d\u043e. \u0422\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0442\u0435\u0441\u0442\u0430 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0443\u044e ip-\u0430\u0434\u0440\u0435\u0441 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u043d\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u0434\u0440\u0435\u0441, \u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u044d\u0441\u043a\u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 (\u043d\u0430\u0437\u043e\u0432\u0435\u043c SmartChangeDNS.ps1).<\/p>\n<pre><code>$MoskowNetworkMask = &quot;192.168.1.0\/24&quot; $RostovNetworkMask = &quot;192.168.2.0\/24&quot;  $IPv4Addresses = GetIPv4Addresses foreach($Address in $IPv4Addresses) {     if(CheckSubnet -cidr $MoskowNetworkMask -ip $Address)     {         #\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 dns 192.168.1.1     }      if(CheckSubnet -cidr $RostovNetworkMask -ip $Address)     {         #\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 dns 192.168.2.1     } }  <\/code><\/pre>\n<p>  \u041e\u043d \u0437\u043d\u0430\u0435\u0442 2 \u043c\u0430\u0441\u043a\u0438 \u0441\u0435\u0442\u0438 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435 \u0438 \u0420\u043e\u0441\u0442\u043e\u0432\u0435. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>GetIPv4Addresses<\/i> \u0432\u0441\u0435 IPv4 \u0430\u0434\u0440\u0435\u0441\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0446\u0438\u043a\u043b\u0435 <i>foreach<\/i> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e\u0434\u0441\u0435\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <i>CheckSubnet<\/i>. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 <i>GetIPv4Addresses<\/i> \u0438 <i>CheckSubnet<\/i> \u0432\u044b \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438. \u0422\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>GetIPv4Addresses<\/i> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f:<\/p>\n<pre><code>describe &quot;SmartChangeDNS&quot; {      it &quot;\u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0432 \u0441\u0435\u0442\u0438 192.168.1.0\/24&quot; {         Mock GetIPv4Addresses {return &quot;192.168.1.115&quot;}         .\\SmartChangeDNS.ps1          $DNSServerAddres = Get-DnsClientServerAddress -InterfaceAlias &quot;Ethernet&quot; -AddressFamily IPv4 | Select -ExpandProperty ServerAddresses          $DNSServerAddres | Should Be &quot;192.168.1.1&quot;     }      it &quot;\u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0432 \u0441\u0435\u0442\u0438 192.168.2.0\/24&quot; {         Mock GetIPv4Addresses {return &quot;192.168.2.20&quot;}         .\\SmartChangeDNS.ps1          $DNSServerAddres = Get-DnsClientServerAddress -InterfaceAlias &quot;Ethernet&quot; -AddressFamily IPv4 | Select -ExpandProperty ServerAddresses          $DNSServerAddres | Should Be &quot;192.168.2.1&quot;     }  }  <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>GetIPv4Addresses<\/i>, \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043d\u0435 \u0442\u0430 \u0435\u0435 \u0432\u0435\u0440\u0441\u0438\u044f, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435, \u0430 \u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 Mock.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Mock \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e, \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h5><i>TestDrive<\/i><\/h5>\n<p>  Pester \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 PS-\u0434\u0438\u0441\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432. \u0422\u0430\u043a\u043e\u0439 \u0434\u0438\u0441\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 Describe \u0438\u043b\u0438 Context. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0434\u0438\u0441\u043a \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u0431\u043b\u043e\u043a\u0435 Describe, \u0442\u043e \u043e\u043d \u0438 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043d\u0435\u043c \u0432\u0438\u0434\u043d\u044b \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0430\u0445 Context. \u0424\u0430\u0439\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u043b\u043e\u043a\u0435 Context \u0441 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0444\u0430\u0439\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u043b\u043e\u043a\u0435 Describe.             <\/p>\n<div class=\"clear\"><\/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=\"http:\/\/habrahabr.ru\/post\/264697\/\"> http:\/\/habrahabr.ru\/post\/264697\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>             <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c1e\/d33\/484\/c1ed3348474f440993d2b57f5c5217ac.png\" align=\"left\"\/>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043d\u0430 PowerShell \u0438 \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445, \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f Pester \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443.  <\/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-263511","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263511","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=263511"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263511\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}