{"id":255240,"date":"2015-04-14T22:38:02","date_gmt":"2015-04-14T18:38:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=255240"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=255240","title":{"rendered":"PowerShell: \u0437\u0430 \u0433\u0440\u0430\u043d\u044c\u044e. \u0427\u0430\u0441\u0442\u044c \u043f\u044f\u0442\u0430\u044f"},"content":{"rendered":"<br \/>\n<blockquote><p><i>\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, \u0434\u0430 \u0432\u044b\u043f\u0435\u0439 \u0447\u0430\u044e.<\/i><br \/>  \u0410\u0432\u0442\u043e\u0440 \u0434\u043e\u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d.<\/p><\/blockquote>\n<p>  \u2026 \u043d\u0435 \u0445\u043e\u0447\u0435\u0448\u044c \u0431\u0443\u043b\u043e\u043a \u2014 \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438. \u0422\u043e\u0447\u043d\u0435\u0435 \u0431\u0443\u0434\u0443\u0442, \u0435\u0436\u0435\u043b\u0438 \u0438\u0445 \u0438\u0441\u043f\u0435\u0447\u044c. \u0411\u043b\u0430\u0433\u043e \u0442\u0435\u0441\u0442\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u0430 \u043e\u0431\u0449\u0435\u043f\u0438\u0442\u043e\u0432\u0441\u043a\u0438\u0445 \u043f\u0435\u043b\u044c\u043c\u0435\u043d\u0435\u0439 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c PowerShell \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0440\u0435\u0446\u0435\u043f\u0442\u0430\u043c \u043d\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c, \u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0442\u043e\u0447\u043d\u043e. \u0418 \u043d\u0435 \u0431\u0435\u0434\u0430, \u0447\u0442\u043e \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u044e\u043c\u0430 \u0441 \u043c\u0430\u043a\u043e\u043c, \u0432 \u0443\u043c\u0435\u043b\u044b\u0445 \u0440\u0443\u043a\u0430\u0445 \u043f\u043b\u044e\u0448\u043a\u0438 \u0438 \u0438\u0437 \u0441\u0438\u043d\u044e\u0448\u043d\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u044b\u0448\u043d\u044b\u043c\u0438 \u0438 \u0440\u0443\u043c\u044f\u043d\u044b\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0425\u043e\u0442\u044f \u043f\u043e\u0441\u0442\u043e\u0439\u0442\u0435, \u043e\u0434\u043d\u0430 \u043f\u043b\u044e\u0448\u043a\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043f\u0440\u0430\u0432\u0434\u0430 \u0437\u0430 \u0445\u043e\u0434\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0432\u0435\u0442\u0440\u0438\u043b\u0430\u0441\u044c \u0438 \u043f\u043e\u0447\u0435\u0440\u0441\u0442\u0432\u0435\u043b\u0430, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u043d\u0435 \u0443\u0442\u0440\u0430\u0442\u0438\u043b\u0430 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"perl\">PS C:\\&gt; man Write-Progress -Detailed <\/code><\/pre>\n<p>  \u041b\u0430\u0434\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u0449\u0438\u043f\u043d\u0435\u043c \u0442\u0440\u043e\u0448\u043a\u0438 \u0442\u0435\u0441\u0442\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u043a\u0443\u043b\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0447\u0443\u0434\u043e.<\/p>\n<pre><code class=\"perl\">$line = {   param(     [Int32]$x,     [Int32]$y,     [String]$text = $null,     [ConsoleColor]$fc, #\u0446\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0430     [ConsoleColor]$bc  #\u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430   )      begin {     $raw = $host.UI.RawUI     $old = $raw.WindowPosition     $con = $raw.WindowSize   }   process {     $pos = $old     $pos.X += $x     $pos.Y += if ($y -lt 0) { $con.Height + $y } else { $y }          switch ([String]::IsNullOrEmpty($text)) {       $true  { $text = [String][Char]32 * $con.Width }       $false { $text += [String][Char]32 * ($con.Width - $text.Length) }     }     $row = $raw.NewBufferCellArray(@($text), $fc, $bc)   }   end {     $raw.SetBufferContents($pos, $row)   } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043b\u044f\u043c\u0431\u0434\u0430-\u043f\u043b\u044e\u0448\u043a\u0430. \u0420\u0430\u0441\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430 \u0432\u043a\u0443\u0441?<\/p>\n<pre><code class=\"perl\">& $line 0 -3 'Awaiting orders' 'Blue' 'White' & $line 0 -2 ' [Q] Quit  [C] Continue' 'Black' 'White' if (($res = Read-Host 'What I should to do?') -eq 'q') {   'Quit...' } elseif ($res -eq 'c') {   'Continue...' } <\/code><\/pre>\n<p>  \u041d\u0435\u0434\u0443\u0440\u0441\u0442\u0432\u0435\u043d\u043d\u043e? \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0438 \u0432\u0441\u0435 \u0436\u0435 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0435\u0442. \u041c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0433\u043b\u0430\u0437\u0443\u0440\u0438?<\/p>\n<pre><code class=\"perl\">if ($host.Runspace.ApartmentState -ne 'STA') {   powershell \/noprofile \/sta $MyInvocation.MyCommand.Path   return }  Add-Type -AssemblyName PresentationFramework  $wnd = New-Object Windows.Window $ink = New-Object Windows.Controls.InkCanvas  $ink.MinWidth = $ink.MinHeight = 100  $wnd.Content = $ink $wnd.SizeToContent = 'WidthAndHeight' $wnd.Title = 'Drawing Board' [void]$wnd.ShowDialog() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/58e\/e56\/376\/58ee56376a6715ed6fafce4b46f87f8c.png\" alt=\"image\"\/><\/p>\n<p>  \u0425\u043c, \u0430 \u0437\u0430\u0447\u0435\u043c, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0435\u043a\u0430\u0440\u044e \u0434\u043e\u0441\u043a\u0430 \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f? \u0418\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0435\u0440\u0435\u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043f\u0435\u043a\u0430\u0440\u044f \u0432 \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u0438? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435\u0442?!<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0438\u0441\u0443\u0435\u043c?<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"perl\">if ($host.Runspace.ApartmentState -ne 'STA') {   powershell \/noprofile \/sta $MyInvocation.MyCommand.Path   return }  Add-Type -AssemblyName PresentationFramework  [void][Windows.Markup.XamlReader]::Load( (New-Object Xml.XmlNodeReader ([xml]@' &lt;Window     xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;     xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;     Width=&quot;423&quot;     Height=&quot;370&quot;     ResizeMode=&quot;NoResize&quot;     WindowStartupLocation=&quot;CenterScreen&quot;     Title=&quot;Butterfly&quot;&gt;   &lt;Path       Fill=&quot;Magenta&quot;       Data=&quot;M204.33 139.83 C196.33 133.33 206.68 132.82 206.58 132.58             C192.33 97.08 169.35 81.41 167.58 80.58 C162.12 78.02             159.48 78.26 160.45 76.97 C161.41 75.68 167.72 79.72             168.58 80.33 C193.83 98.33 207.58 132.33 207.58 132.33             C207.58 132.33 209.33 133.33 209.58 132.58 C219.58 103.08             239.58 87.58 246.33 81.33 C253.08 75.08 256.63 74.47             247.33 81.58 C218.58 103.58 210.34 132.23 210.83 132.33             C222.33 134.83 211.33 140.33 211.83 139.83 C214.85 136.81             214.83 145.83 214.83 145.83 C214.83 145.83 231.83 110.83             298.33 66.33 C302.43 63.59 445.83 -14.67 395.83 80.83             C393.24 85.79 375.83 105.83 375.83 105.83 C375.83 105.83             377.33 114.33 371.33 121.33 C370.3 122.53 367.83 134.33             361.83 140.83 C360.14 142.67 361.81 139.25 361.83 140.83             C362.33 170.83 337.76 170.17 339.33 170.33 C348.83 171.33             350.19 183.66 350.33 183.83 C355.83 190.33 353.83 191.83             355.83 194.83 C366.63 211.02 355.24 210.05 356.83 212.83             C360.83 219.83 355.99 222.72 357.33 224.83 C360.83 230.33             354.75 233.84 354.83 235.33 C355.33 243.83 349.67 240.73             349.83 244.33 C350.33 255.33 346.33 250.83 343.83 254.83             C336.33 266.83 333.46 262.38 332.83 263.83 C329.83 270.83             325.81 269.15 324.33 270.83 C320.83 274.83 317.33 274.83             315.83 276.33 C308.83 283.33 304.86 278.39 303.83 278.83             C287.83 285.83 280.33 280.17 277.83 280.33 C270.33 280.83             271.48 279.67 269.33 277.83 C237.83 250.83 219.33 211.83             215.83 206.83 C214.4 204.79 211.35 193.12 212.33 195.83             C214.33 201.33 213.33 250.33 207.83 250.33 C202.33 250.33             201.83 204.33 205.33 195.83 C206.43 193.16 204.4 203.72             201.79 206.83 C196.33 213.33 179.5 250.83 147.59 277.83             C145.42 279.67 146.58 280.83 138.98 280.33 C136.46 280.17             128.85 285.83 112.65 278.83 C111.61 278.39 107.58 283.33             100.49 276.33 C98.97 274.83 95.43 274.83 91.88 270.83             C90.39 269.15 86.31 270.83 83.27 263.83 C82.64 262.38             79.73 266.83 72.13 254.83 C69.6 250.83 65.54 255.33 66.05             244.33 C66.22 240.73 60.48 243.83 60.99 235.33 C61.08             233.84 54.91 230.33 58.45 224.83 C59.81 222.72 54.91             219.83 58.96 212.83 C60.57 210.05 49.04 211.02 59.97             194.83 C62 191.83 59.97 190.33 65.54 183.83 C65.69 183.66             67.06 171.33 76.69 170.33 C78.28 170.17 53.39 170.83 53.9             140.83 C53.92 139.25 55.61 142.67 53.9 140.83 C47.82             134.33 45.32 122.53 44.27 121.33 C38.19 114.33 39.71             105.83 39.71 105.83 C39.71 105.83 22.08 85.79 19.46 80.83             C-31.19 -14.67 114.07 63.59 118.22 66.33 C185.58 110.83             202 145.83 202 145.83 C202 145.83 202.36 143.28 203             141.83 C203.64 140.39 204.56 140.02 204.33 139.83 z&quot; \/&gt; &lt;\/Window&gt; '@))).ShowDialog() <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/e65\/c72\/d07\/e65c72d075324b90394bfcdc020e8d46.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430\u0434\u043e\u0435\u043b\u043e \u0431\u044b\u0442\u044c \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u043e\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0441\u0435\u0431\u044f \u043d\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u043f\u0440\u0438\u0449\u0435 \u0444\u043e\u0442\u043e\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430?<\/p>\n<pre><code class=\"perl\">Add-Type -AssemblyName System.Drawing  $img = [Drawing.Image]::FromFile('orig.png') $bmp = New-Object Drawing.Bitmap $img  $ia = New-Object Drawing.Imaging.ImageAttributes $cm = New-Object Drawing.Imaging.ColorMatrix $cm.Matrix40 = $cm.Matrix41 = $cm.Matrix42 = 1 $cm.Matrix00 = $cm.Matrix11 = $cm.Matrix22 = -1 $ia.SetColorMatrix($cm)  $gfx = [Drawing.Graphics]::FromImage($bmp) $gfx.DrawImage(   $bmp, (New-Object Drawing.Rectangle 0, 0, $bmp.Width, $bmp.Height),   0, 0, $bmp.Width, $bmp.Height, [Drawing.GraphicsUnit]::Pixel, $ia ) $gfx.Flush()  $bmp.Save(   ($fs = New-Object IO.FileStream('negate.png', [IO.FileMode]::Create)),   $img.RawFormat )  $fs.Close() $img.Dispose() <\/code><\/pre>\n<p>  <nobr><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/d18\/e79\/1f4\/d18e791f4109186e0f3f22d05e3609e6.png\" alt=\"orig\" width=\"270\" height=\"360\"\/><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/ad1\/7fb\/ad1\/ad17fbad103f093fb0b287d43e4104c1.png\" alt=\"negate\" width=\"270\" height=\"360\"\/><\/nobr><\/p>\n<p>  \u041f\u043b\u044e\u0448\u043a\u0438 \u043d\u0430\u0439\u0434\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e.     \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\/255765\/\"> http:\/\/habrahabr.ru\/post\/255765\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<blockquote><p><i>\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, \u0434\u0430 \u0432\u044b\u043f\u0435\u0439 \u0447\u0430\u044e.<\/i><br \/>  \u0410\u0432\u0442\u043e\u0440 \u0434\u043e\u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d.<\/p><\/blockquote>\n<p>  \u2026 \u043d\u0435 \u0445\u043e\u0447\u0435\u0448\u044c \u0431\u0443\u043b\u043e\u043a \u2014 \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438. \u0422\u043e\u0447\u043d\u0435\u0435 \u0431\u0443\u0434\u0443\u0442, \u0435\u0436\u0435\u043b\u0438 \u0438\u0445 \u0438\u0441\u043f\u0435\u0447\u044c. \u0411\u043b\u0430\u0433\u043e \u0442\u0435\u0441\u0442\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u0430 \u043e\u0431\u0449\u0435\u043f\u0438\u0442\u043e\u0432\u0441\u043a\u0438\u0445 \u043f\u0435\u043b\u044c\u043c\u0435\u043d\u0435\u0439 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c PowerShell \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0440\u0435\u0446\u0435\u043f\u0442\u0430\u043c \u043d\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c, \u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0442\u043e\u0447\u043d\u043e. \u0418 \u043d\u0435 \u0431\u0435\u0434\u0430, \u0447\u0442\u043e \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u044e\u043c\u0430 \u0441 \u043c\u0430\u043a\u043e\u043c, \u0432 \u0443\u043c\u0435\u043b\u044b\u0445 \u0440\u0443\u043a\u0430\u0445 \u043f\u043b\u044e\u0448\u043a\u0438 \u0438 \u0438\u0437 \u0441\u0438\u043d\u044e\u0448\u043d\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u044b\u0448\u043d\u044b\u043c\u0438 \u0438 \u0440\u0443\u043c\u044f\u043d\u044b\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-255240","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255240","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=255240"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255240\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}