{"id":253004,"date":"2015-03-13T12:00:03","date_gmt":"2015-03-13T08:00:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253004"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253004","title":{"rendered":"Powershell \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u0432"},"content":{"rendered":"<p> \t\t\t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/f81\/10f\/30b\/f8110f30beab4c33a7beb884e814e0f4.jpg\"\/> <\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u00ab\u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442\u00bb \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PowerShell \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u0432. \u0412\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0438 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043d\u0435\u0439, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043c\u0438\u0440\u044f\u0435\u0442\u0435\u0441\u044c \u0441 \u0442\u0435\u043c \u0444\u0430\u043a\u0442\u043e\u043c, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u043b\u0435\u043d\u0438\u0432\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u0438\u0442\u0440\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c. \u0418, \u043d\u0435 \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u044f, \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438.<br \/>   <a name=\"habracut\"><\/a><br \/>  \u0423 \u043c\u0435\u043d\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435. \u041f\u043e\u0447\u0442\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Windows \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u00ab\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442 Microsoft, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432\u00bb. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u043d\u043e \u00ab\u043a\u043b\u0430\u0441\u0441\u0441\u044b\u00bb \u0438\u0437 .NET. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0441 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u00ab\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u00bb \u0438 \u043f\u0438\u0448\u0435\u043c <i>powershell<\/i>. \u041f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u043e\u043a\u043e\u0448\u0435\u0447\u043a\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0432 powershelle \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u0432\u0441\u0435\u043c \u043d\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442 \u044d\u0442\u043e <i>Get-Help<\/i>. \u041e\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <code>Get-Help Get-Help<\/code><\/p>\n<p>  \u2013 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u043f\u0440\u0430\u0432\u043a\u0443 \u043f\u043e <i>Get-Help<\/i>. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043b\u0430\u0432\u0438\u0448\u0438 Tab.<\/p>\n<p>  \u041a\u043e\u043d\u0441\u043e\u043b\u044c \u2014 \u044d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u043d\u0435\u0439 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c Powershell ISE.<br \/>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438: \u00ab\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u00bb \u2014 <i>powershell_ise<\/i>. <\/p>\n<p>  \u0412\u0438\u0434\u0438\u043c \u043c\u0438\u043d\u0438 IDE c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0438\u043c\u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0412 \u043d\u0435\u0439 \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0440\u0443\u0434\u044b \u0432 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c ps1.<\/p>\n<p>  \u041f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. \u041f\u043e\u0442\u0435\u0440\u044f-\u043f\u043e\u0442\u0435\u0440\u044c \u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c PowerShell \u0441 \u0430\u0434\u043c\u0438\u043d\u0441\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0438 \u043f\u0438\u0448\u0435\u043c: <\/p>\n<p>  <code>Set-ExecutionPolicy RemoteSigned<\/code> <\/p>\n<p>  \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u2013 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0436 \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435. \u041d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u043d\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0439\u0434\u0435\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u0442\u0430\u043b\u0430 \u043f\u043e\u0440\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <i>Get-ChildItem<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0430\u043f\u043a\u0438. <br \/>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0430\u043c\u0430 \u043f\u0430\u043f\u043a\u0430 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c<i> -Path<\/i>. <br \/>  <i>Include<\/i> \u2014 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e \u043c\u0430\u0441\u043a\u0435, <br \/>  <i>Recurse<\/i> \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u043f\u043a\u0430\u0445.<\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0438\u0434\u0430:<\/p>\n<p>  <code>Get-ChildItem -Path \u201cD:\\Logs\u201d -Include *.log -Exclude &quot;!*&quot; \u2013Recurse<\/code><\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0449\u0435\u043c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c .log, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 !, \u0432 \u043f\u0430\u043f\u043a\u0435 D:\\Logs. \u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0447\u0442\u043e \u043d\u0430\u0448\u0435\u043b <i>Get-ChildItem <\/i> \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c | \u2014 \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440.<\/p>\n<p>  <code>Get-ChildItem -Path $input_path -Include *.log -Exclude &quot;!*&quot; -Recurse | select-string -Pattern $text -Encoding &quot;Default&quot; -Context 0,10<\/code><\/p>\n<p>  \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438: \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u0438\u0449\u0435\u043c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0447\u0442\u043e \u0434\u0430\u043b \u043d\u0430\u043c <i>Get-ChildItem <\/i> \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043e\u0439 <i>$text<\/i>. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0432 \u043b\u043e\u0433\u0430\u0445. <i>-Encoding<\/i> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0438\u0445 \u043b\u043e\u0433\u0430\u0445, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043d\u0435 \u043a\u0440\u0430\u043a\u043e\u0437\u044f\u0431\u0440\u0430\u043c\u0438. <i>-\u0421\u043entext<\/i> (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Powershell \u0432\u0435\u0440\u0441\u0438\u0438 2.0) \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e<i> $text<\/i>. \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u00ab$\u00bb.<\/p>\n<p>  <code>$text = \u2018(Fatal|Error|access|)\u2019<\/code> <br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043c\u044b \u0438\u0449\u0435\u043c \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 Fatal \u0438\u043b\u0438 Error \u0438\u043b\u0438 acces.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0433\u043e\u0442\u043e\u0432, \u043d\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442. \u041c\u044b \u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u043a\u0443\u0447\u0443 \u043b\u043e\u0433\u043e\u0432 \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0435\u0448\u0430\u043d\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a. \u041b\u0443\u0447\u0448\u0435 \u043f\u0440\u0438\u0447\u0435\u0441\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0438, \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <i>$_<\/i> \u2014 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u043b\u043e\u0433\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <i>$_.FileName<\/i> \u2014 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430, <i>$_.LineNumber<\/i> \u2014 \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435 \u0441\u043e\u0432\u043f\u0430\u043b \u043d\u0430\u0448 \u0442\u0435\u043a\u0441\u0442, \u043d\u0443 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p>  <code>$text = \u2018(Fatal|Error|access)\u2019 Get-ChildItem -Path $input_path -Include *.log -Exclude &quot;!*&quot; -Recurse | select-string -Pattern $text -Encoding &quot;Default&quot; -Context 0,10 | foreach {@($_.FileName), @($_.LineNumber), @($_.Line), @($_.Context.PostContext)} &gt; $output_file<\/code><\/p>\n<p>  <i>&gt; <\/i> \u2014 \u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0434 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u0443\u0436\u0434\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0433\u0434\u0435 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u043e. \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043b\u043e\u0433\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u2014 &quot;(128 \u043c\u0441)&quot;. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 1000 \u043c\u0441. \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $text=\u2019(\\d{3,} \u043c\u0441)\u2019 \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u00ab\u0441\u043a\u043e\u0431\u043e\u0447\u043a\u0443\u00bb, \u0437\u0430 \u043d\u0435\u0439 \u0447\u0438\u0441\u043b\u043e, \u0433\u0434\u0435 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 3 \u0437\u043d\u0430\u043a\u043e\u0432, \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u043b, \u043f\u043e\u0442\u043e\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u00ab\u043c\u0441\u00bb \u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u00ab\u0441\u043a\u043e\u0431\u043e\u0447\u043a\u0443\u00bb.<\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0441\u0430\u043c\u0443\u044e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<p>  <code>Select-string -Pattern &quot;data\\d$&quot; -Path input.txt | Group-Object Line | Sort-Object Count -Descending | Select Count,Name -First 2 &gt; out.txt<\/code><\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u044f \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u0434\u043e\u0433\u0430\u0434\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438.<\/p>\n<p>  \u0417\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0441 \u043b\u043e\u0433\u0430\u043c\u0438 \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043b\u043e\u0449\u0430\u0434\u043e\u043a. \u0420\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u2013 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b, \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0422\u0443\u0442 \u0432\u044b\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Powershell. \u0418\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <code>Enable-PSRemoting -Force<\/code><\/p>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0432\u0443\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u2014 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c WS (http:\/\/en.wikipedia.org\/wiki\/WS-Management). \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<p>  <code>Test-WsMan COMPUTER<\/code><\/p>\n<p>  \u041a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>  <code>Invoke-Command -ComputerName COMPUTER -FilePath &quot;d:\\SCRIPT\\script.ps1&quot;<\/code><\/p>\n<p>  Script.ps1 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 COMPUTER. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <i>Start-Process<\/i>, \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u041f\u041e, \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0443.<\/p>\n<p>  \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0430\u0439\u043b. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <code> foreach ($computer in $computers) {             if (test-Connection -Cn $computer -quiet) {                         Copy-Item $source -Destination \\\\$computer\\$dest -Recurse                         } else {                                                &quot;$computer is not online&quot;                                                }                                    }  <\/code><\/p>\n<p>  \u0413\u0434\u0435, <i>computers = @(\u201cCOMPUTER\u201d, \u201cCOMPUTER1\u201d, \u201cCOMPUTER2\u201d)<\/i> \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432,<br \/>  <i>$source<\/i> = \u00abc:\\files\u00bb \u2014 \u043f\u0430\u043f\u043a\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c,<br \/>  <i>$dest<\/i> = \u00abc$\u00bb \u2014 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<h4>\u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u044e\u0449\u0438\u0445\/\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439<\/h4>\n<p>  <a href=\"http:\/\/habrahabr.ru\/post\/242425\/\">Jump Start \u0432 PowerShell (\u0447\u0430\u0441\u0442\u044c I)<\/a> <br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/242445\/\">Jump Start \u0432 PowerShell (\u0447\u0430\u0441\u0442\u044c II)<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/113913\/\">\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438 \u0434\u043b\u044f \u043f\u0430\u0443\u044d\u0440\u0448\u0435\u043b\u044c\u0448\u0438\u043a\u043e\u0432<\/a><br \/>  <a href=\"http:\/\/itband.ru\/2010\/05\/regular-expressions-windows-powershell\/\">\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 Powershell<\/a><br \/>  <a href=\"https:\/\/regex101.com\/\">\u041f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/a><\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0438 \u0432\u0441\u0435. \u0411\u0443\u0434\u044c\u0442\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044b, \u0438 \u0447\u0430\u0449\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0431\u044d\u043a\u0430\u043f\u044b. \t\t\t<\/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\/252957\/\"> http:\/\/habrahabr.ru\/post\/252957\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/f81\/10f\/30b\/f8110f30beab4c33a7beb884e814e0f4.jpg\"\/> <\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u00ab\u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442\u00bb \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PowerShell \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u0432. \u0412\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0438 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043d\u0435\u0439, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043c\u0438\u0440\u044f\u0435\u0442\u0435\u0441\u044c \u0441 \u0442\u0435\u043c \u0444\u0430\u043a\u0442\u043e\u043c, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u043b\u0435\u043d\u0438\u0432\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u0438\u0442\u0440\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c. \u0418, \u043d\u0435 \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u044f, \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438.   <\/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-253004","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253004","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=253004"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253004\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}