{"id":255519,"date":"2015-04-19T16:23:03","date_gmt":"2015-04-19T12:23:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=255519"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=255519","title":{"rendered":"PowerShell: \u0437\u0430 \u0433\u0440\u0430\u043d\u044c\u044e. \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f"},"content":{"rendered":"<p>     \t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c7b\/8c2\/5ab\/c7b8c25ab6c9a09e0e5782b06a1ddd68.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 PowerShell \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a WMI, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0434\u0442\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0447\u0435\u0440\u0442\u043e\u0433\u0438 WMI \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 WMI \u043f\u043e\u0434\u0434\u0440\u0430\u0437\u043d\u0438\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0444\u0438\u0433\u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u2014 \u043f\u0440\u0435\u0446\u0435\u0434\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u0438 \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u0441\u0435\u0446\u0435\u043b\u043e \u0443\u043f\u043e\u0432\u0430\u0442\u044c \u043d\u0430 WMI \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u0434\u0430 \u0438 \u0437\u043d\u0430\u043d\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0438\u0448\u043d\u0438\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0438 \u0440\u0430\u0434\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u043e\u0432\u0441\u0435 \u0440\u0435\u0448\u0435\u043d\u044b \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u043e \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c\u044e PowerShell \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0434\u0435\u0441\u043a\u0430\u0442\u044c, \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u043c\u0435\u0440\u0442\u0432\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0445\u043e\u0442\u044c \u0438 \u043e\u0442\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043b\u0430\u043d, \u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0435 \u0441\u043e \u0441\u0447\u0435\u0442\u043e\u0432 \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043d\u043e \u043d\u0435 \u0432 \u0432\u0438\u0434\u0443 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0438, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a <s>\u043f\u0430\u0440\u0442\u0438\u0439\u043d\u044b\u0435<\/s> MVP \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u0443\u0442\u044c \u0434\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"perl\">PS C:\\&gt; ([Regex]'(?&lt;=\\&quot;).*(?=\\&quot;)').Match( &gt;&gt; (gp Registry::HKCR\\http\\shell\\open\\command).'(default)' &gt;&gt; ).Value C:\\Program Files\\Internet Explorer\\iexplore.exe PS C:\\&gt; <\/code><\/pre>\n<p>  \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 assoc \u0438 ftype \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"perl\">PS C:\\&gt; (cmd \/c ftype (cmd \/c assoc .htm).Split('=')[1]).Split('&quot;')[1] C:\\Program Files\\Internet Explorer\\iexplore.exe PS C:\\&gt; <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c uptime \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2014 \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u0432\u0435\u0434\u0435\u0442 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e WMI.<\/p>\n<pre><code class=\"perl\">$w = gwmi Win32_OperatingSystem 'up {0} day{1}, {2:D2}:{3:D2}:{4:D2}' -f ($u = (Get-Date) - $w.ConvertToDateTime(   $w.LastBootUptime )).Days, $(if ($u.Days -gt 1) {'s'}), $u.Hours, $u.Minutes, $u.Seconds <\/code><\/pre>\n<p>  \u0415\u0436\u0435\u043b\u0438 \u043a\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442 \u0442\u0430\u043a\u0443\u044e \u0448\u0442\u0443\u043a\u0443 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u043a\u0430\u043a <i>typeperf<\/i>, \u0442\u043e\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0435 \u00ab\u0412\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b\u00bb, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c\u0443 \u0432\u0438\u0434\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"bash\">@echo off   setlocal & chcp 1251&gt;nul     for \/f &quot;tokens=2 delims=,&quot; %%i in (       'typeperf &quot;\\\u0421\u0438\u0441\u0442\u0435\u043c\u0430\\\u0412\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b&quot; -sc 1 ^| findstr \/rc:&quot;\\:&quot;'     ) do set &quot;sec=%%i&quot;     set &quot;sec=%sec:&quot;=%&quot;     for \/f &quot;tokens=1 delims=.&quot; %%i in (&quot;%sec%&quot;) do set &quot;sec=%%i&quot;     set \/a &quot;ss=sec%%60&quot;, &quot;sec\/=60&quot;, &quot;mm=sec%%60&quot;, &quot;sec\/=60&quot;, &quot;hh=sec%%24&quot;, &quot;dd=sec\/24&quot;     if %hh% lss 10 set &quot;hh=0%hh%&quot;     if %mm% lss 10 set &quot;mm=0%mm%&quot;     if %ss% lss 10 set &quot;ss=0%ss%&quot;     echo.up %dd% days, %hh%:%mm%:%ss%   endlocal & chcp 866&gt;nul exit \/b <\/code><\/pre>\n<p>  \u0412 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043d\u0430 PowerShell \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a:<\/p>\n<pre><code class=\"perl\">$pc = New-Object Diagnostics.PerformanceCounter('System', 'System Up Time', $true) [void]$pc.NextValue() 'up {0} day{1}, {2:D2}:{3:D2}:{4:D2}' -f (   $u = [TimeSpan]::FromSeconds($pc.NextValue()) ).Days, $(if ($u.Days -gt 1) {'s'}), $u.Hours, $u.Minutes, $u.Seconds <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u0439\u043c\u0430\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0443\u0445 \u0437\u0430\u0439\u0446\u0435\u0432: \u043e\u0431\u043e\u0448\u043b\u0438 WMI \u0438 \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0442\u043e \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0437\u044f\u043b\u0438 \u0435\u0435 \u043d\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448. \u041a \u0441\u043b\u043e\u0432\u0443, \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f uptime (\u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438).<\/p>\n<p>  <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/467\/893\/b95\/467893b957ba096df94515d3347cdb37.png\" alt=\"linux uptime\" height=\"230\" width=\"670\"\/><br \/>  <i>C# REPL \u0432 Linux: \u0447\u0435\u043c \u043d\u0435 PowerShell?<\/i><\/p>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435, \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u0442\u0435\u043c\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u0430 \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043e\u0431\u044a\u044f\u0442\u044c \u0435\u0435 \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043e\u0431\u0437\u043e\u0440\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u0435\u0435 \u0432\u0441\u0435 \u0441\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0430\u0437\u0435, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u044f\u0445. \u041d\u043e, \u043a\u0430\u043a \u0431\u044b \u043f\u0430\u0440\u0430\u0434\u043e\u043a\u0441\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043d\u0438 \u0437\u0432\u0443\u0447\u0430\u043b\u043e, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0442 \u0438 \u0431\u044b\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u0432\u0441\u0435 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u0432\u043e\u0438\u0434\u0438\u0442\u0441\u044f \u043a \u0447\u0442\u0435\u043d\u0438\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0443\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u0441\u0431\u043e\u0440\u043e\u043a \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b .NET \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u0432\u0440\u043e\u0434\u0435 ILDASM \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043c \u0441 \u043a\u043e\u0434\u043e\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0441\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445\u2026 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u043c\u0435\u043d \u0442\u0438\u043f\u043e\u0432, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043d\u0438\u0437\u0438\u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432? \u0415\u0441\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, ISE \u0438 Vim \u0441 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435? \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0430\u043b\u0438c\u044c \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u0435\u043b\u0438 \u0442\u0438\u043f\u043e\u0432 \u2014 \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0440\u0430 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u0445.<\/p>\n<pre><code class=\"perl\">Set-Content function:_from {   param(     [Parameter(Mandatory=$true, Position=0)]     [String]$NameSpace,          [Parameter(Mandatory=$true, Position=1)]     [ScriptBlock]$Import   )      $ret = $null   $arr = [accelerators]::Get.Keys      [Management.Automation.PSParser]::Tokenize($Import, [ref]$ret) | % {     if ($_.Type -match 'Command' -and $arr -notcontains $_.Content) {       [accelerators]::Add($_.Content, (&quot;$($NameSpace).$($_.Content)&quot;))     }   } } <\/code><\/pre>\n<p>  \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0432 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 Python \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code class=\"perl\">PS C:\\&gt; _from Runtime.InteropServices -import { &gt;&gt; Marshal; HandleRef; GCHandle; &gt;&gt; } &gt;&gt; PS C:\\&gt; [GCHandle]  IsPublic IsSerial Name                                     BaseType -------- -------- ----                                     -------- True     False    GCHandle                                 System.ValueType  PS C:\\&gt; <\/code><\/pre>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0439, \u043d\u0435\u0436\u0435\u043b\u0438 \u043d\u0430\u0431\u0438\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"perl\">PS C:\\&gt; [Runtime.InteropServices.GCHandle] ... PS C:\\&gt; <\/code><\/pre>\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\/256075\/\"> http:\/\/habrahabr.ru\/post\/256075\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c7b\/8c2\/5ab\/c7b8c25ab6c9a09e0e5782b06a1ddd68.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 PowerShell \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a WMI, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0434\u0442\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430, \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0447\u0435\u0440\u0442\u043e\u0433\u0438 WMI \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 WMI \u043f\u043e\u0434\u0434\u0440\u0430\u0437\u043d\u0438\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0444\u0438\u0433\u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u2014 \u043f\u0440\u0435\u0446\u0435\u0434\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u0438 \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u0441\u0435\u0446\u0435\u043b\u043e \u0443\u043f\u043e\u0432\u0430\u0442\u044c \u043d\u0430 WMI \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u0434\u0430 \u0438 \u0437\u043d\u0430\u043d\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0438\u0448\u043d\u0438\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-255519","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255519","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=255519"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255519\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}