{"id":347069,"date":"2023-03-21T15:03:48","date_gmt":"2023-03-21T15:03:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347069"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347069","title":{"rendered":"<span>\u0423\u0436\u0430\u0441\u044b PowerShell<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041c\u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <strong>PowerShell<\/strong>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u0438\u043c\u0435\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u0438 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0435. \u0423\u0440\u043e\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u044c <strong>PowerShell<\/strong> \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 <strong>Python<\/strong>. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, c \u043b\u0438\u0446\u0430 \u043d\u0435 \u0432\u043e\u0434\u0443 \u043f\u0438\u0442\u044c &#8212; \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e? \u041d\u043e \u043d\u0435\u0442, \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 <strong>PowerShell<\/strong> \u0435\u0441\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u0430\u0440\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0420\u0430\u0441\u0445\u043b\u044f\u0431\u0430\u043d\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u042d\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442. \u0414\u0430\u0436\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 <strong>Python<\/strong> \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"powershell\">PS C:\\> Write-host \"Value is: $newvar\" Value is: PS C:\\><\/code><\/pre>\n<p>\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u0430\u0436\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/24b\/50b\/126\/24b50b126146d52da32f50684df6b9b3.png\" width=\"456\" height=\"92\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24b\/50b\/126\/24b50b126146d52da32f50684df6b9b3.png\"\/><\/figure>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/h2>\n<p>\u0417\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"powershell\">@\" One Two Three \"@ | Out-File x.tmp $f = Get-Content \"x.tmp\" Write-Host \"Inside the file: $f\"  Output: Inside the file: One Two Three<\/code><\/pre>\n<p><em>Get-Content<\/em> \u0432\u044b\u0434\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a. \u0420\u0430\u0441\u0445\u043b\u044f\u0431\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u043e\u043d\u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0442\u0441\u044f &#8212; \u0445\u043e\u0440\u043e\u0448\u043e \u0447\u0442\u043e \u0445\u043e\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0442\u043e \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<pre><code class=\"powershell\">@\" One Two Three \"@ | Out-File x.tmp $f = (Get-Content \"x.tmp\")[0] Write-Host \"Inside the file: $f\"  Output: Inside the file: One<\/code><\/pre>\n<p>\u041d\u0443 \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"powershell\">@\" One \"@ | Out-File x2.tmp $f = (Get-Content \"x2.tmp\")[0] Write-Host \"Inside the file: $f\"  Output: Inside the file: O<\/code><\/pre>\n<p>\u0427\u0442\u043e, \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435? \u041a\u0443\u0434\u0430 \u0434\u0435\u043b\u0438\u0441\u044c &#8216;ne&#8217;? \u041e\u0442\u0432\u0435\u0442 \u0448\u043e\u043a\u0438\u0440\u0443\u0435\u0442:<\/p>\n<pre><code class=\"powershell\">(Get-Content \"x.tmp\").GetType() (Get-Content \"x2.tmp\").GetType()  IsPublic IsSerial Name                                     BaseType -------- -------- ----                                     -------- True     True     Object[]                                 System.Array True     True     String                                   System.Object<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0437 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u0442\u043e \u0437\u0430\u0447\u0435\u043c \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c \u0441\u043a\u043e\u0431\u043a\u0438 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u041f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0432 notepad, \u0447\u0442\u043e <em>string<\/em>, <em>string&lt;br><\/em> \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0430 \u0432\u043e\u0442 <em>string&lt;br>&lt;br><\/em> \u0438\u043b\u0438 <em>string&lt;br>&lt;sp><\/em> \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b &#8212; \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 notepad \u0432\u0441\u0435 \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0442\u043b\u0438\u0447\u0438\u043c\u044b \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430!<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"powershell\">$f = Get-Content \"x.tmp\" if ($f.GetType().Name -eq \"Object[]\") {   $firstln = $f[0] } else {   $firstln = $f } Write-Host $firstln<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e? \u041d\u0435\u0442! \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0443\u0441\u0442\u0430 (\u0442\u0430\u043c \u043d\u0435\u0442 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u0430), \u0442\u043e <em>Get-Content<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>$null<\/em>! \u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.management\/get-content?view=powershell-7.3\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Microsoft<\/a> \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u042d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u0441 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"powershell\">$found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select * from sysdatabases\" $found.getType() $found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select top 1 * from sysdatabases\" $found.getType() $found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select top 0 * from sysdatabases\" $found.getType()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2f3\/e49\/064\/2f3e49064d8a1b459dddef5738ead0d1.png\" width=\"688\" height=\"265\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f3\/e49\/064\/2f3e49064d8a1b459dddef5738ead0d1.png\"\/><\/figure>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0432 \u043a\u043e\u0434\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"powershell\">$cnt = $found.Rows.Count if ($found.getType().FullName -eq 'System.Management.Automation.PSCustomObject')    { $cnt = 1; }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b <strong>Python<\/strong> \u0441 \u0437\u0430\u0432\u0438\u0441\u0442\u044c\u044e \u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0435\u0440\u0432\u043d\u043e \u043a\u0443\u0440\u044f\u0442 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u043a\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u043b\u0438\u0448\u0435\u043d\u044b \u044d\u0441\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u043e\u0448\u043b\u0430 \u0437\u0440\u044f.<\/p>\n<p>\u0413\u0434\u0435-\u0442\u043e \u043f\u043b\u0430\u0447\u0443\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438 \u043e\u0434\u043d\u043e\u0433\u043e, \u0438 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0434\u043d\u043e\u0433\u043e &#171;\u0442\u0438\u043f\u0430&#187;. \u041d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 <strong>PowerShell<\/strong> \u043f\u043e\u0445\u043e\u0436\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u0432 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0435: <em>\u043d\u043e\u043b\u044c, \u043e\u0434\u0438\u043d, \u043c\u043d\u043e\u0433\u043e<\/em>.<\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0441\u0442\u0440\u0435\u043b<\/h2>\n<p>\u0412\u0430\u043c \u0435\u0449\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 <strong>PowerShell<\/strong>? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u044d\u0442\u043e\u043c. \u0412\u043e\u0442 \u0435\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"powershell\">function something([string]$file, [string]$p2)   {   New-item $file   return \"always OK\" }  $res = something \"xxx.tmp\" \"beta\" Write-host \"Result: $res\" $res.GetType()<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 <strong>$res<\/strong>? \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a92\/ad7\/248\/a92ad72480a03eeccd062d3311527cab.png\" width=\"715\" height=\"155\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a92\/ad7\/248\/a92ad72480a03eeccd062d3311527cab.png\"\/><\/figure>\n<p>\u041a\u0430\u043a\u043e\u0433\u043e \u0447\u0435\u0440\u0442\u0430? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 <strong>PowerShell<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 <em>return<\/em> (\u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c), \u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0445\u043e\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412\u044b\u0432\u043e\u0434 <em>new-Item<\/em> \u043f\u0440\u0438\u043b\u0435\u043f\u0438\u043b\u0441\u044f \u0434\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0432\u0435\u043b\u0438 \u0432 <em>return<\/em>. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u0434\u043e\u043f\u0438\u0441\u0430\u0432 <em>| Out-Null<\/em> \u043f\u043e\u0441\u043b\u0435 <em>New-Item<\/em>, \u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0412\u0430\u0441\u0435\u0439 \u041f\u0443\u043f\u043a\u0438\u043d\u044b\u043c, <em>\u0432\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/em>. <em>\u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0438-\u0447\u0435-\u0433\u043e.<\/em><\/p>\n<p>\u041f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0438 \u0432 \u0441\u0432\u043e\u0435\u043c <a href=\"https:\/\/www.actionatdistance.com\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a> \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430 <strong>PowerShell<\/strong>. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043c\u0430\u0445\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 <strong>Ubuntu<\/strong> \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/mssql\" rel=\"noopener noreferrer nofollow\"><strong>MSSQL<\/strong><\/a>, <a href=\"https:\/\/www.actionatdistance.com\/postgres\" rel=\"noopener noreferrer nofollow\"><strong>Postgre<\/strong><\/a> \u0438 <a href=\"https:\/\/www.actionatdistance.com\/mysql\" rel=\"noopener noreferrer nofollow\"><strong>MySQL<\/strong><\/a> \u0441 <strong>PowerShell<\/strong> \u043d\u0430 <strong>Python<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043f\u043e\u0434 <strong>Ubuntu<\/strong>, \u044f \u043d\u0435 \u043c\u043e\u0433 \u0443\u0436\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b <strong>pwsh<\/strong> \u0434\u043b\u044f <strong>Ubuntu<\/strong> \u0438 \u0443\u0431\u0435\u0434\u0438\u043b\u0441\u044f, \u0447\u0442\u043e <strong>PowerShell<\/strong> \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0434\u0430\u0436\u0435 \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u0432\u0441\u0435 case-insensitive. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b <strong>Python<\/strong>-\u0432\u0435\u0440\u0441\u0438\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043f\u043e\u0434 <strong>Windows<\/strong> \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u0443\u0441\u043f\u043e\u043a\u043e\u0438\u043b <em>\u0435\u0435 \u0432\u0435\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/em>. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, <strong>Python<\/strong> \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0435\u0437\u0434\u0435 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. <strong>PowerShell<\/strong> \u0442\u0443\u043f\u0438\u0442 \u0434\u043e\u043b\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 GUI \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/723730\/\"> https:\/\/habr.com\/ru\/post\/723730\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041c\u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <strong>PowerShell<\/strong>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u0438\u043c\u0435\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u0438 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0435. \u0423\u0440\u043e\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u044c <strong>PowerShell<\/strong> \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 <strong>Python<\/strong>. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, c \u043b\u0438\u0446\u0430 \u043d\u0435 \u0432\u043e\u0434\u0443 \u043f\u0438\u0442\u044c &#8212; \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e? \u041d\u043e \u043d\u0435\u0442, \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 <strong>PowerShell<\/strong> \u0435\u0441\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u0430\u0440\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0420\u0430\u0441\u0445\u043b\u044f\u0431\u0430\u043d\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u042d\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442. \u0414\u0430\u0436\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 <strong>Python<\/strong> \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"powershell\">PS C:\\> Write-host \"Value is: $newvar\" Value is: PS C:\\><\/code><\/pre>\n<p>\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u0430\u0436\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f:<\/p>\n<figure class=\"\"><\/figure>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/h2>\n<p>\u0417\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"powershell\">@\" One Two Three \"@ | Out-File x.tmp $f = Get-Content \"x.tmp\" Write-Host \"Inside the file: $f\"  Output: Inside the file: One Two Three<\/code><\/pre>\n<p><em>Get-Content<\/em> \u0432\u044b\u0434\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a. \u0420\u0430\u0441\u0445\u043b\u044f\u0431\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u043e\u043d\u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0442\u0441\u044f &#8212; \u0445\u043e\u0440\u043e\u0448\u043e \u0447\u0442\u043e \u0445\u043e\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0442\u043e \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<pre><code class=\"powershell\">@\" One Two Three \"@ | Out-File x.tmp $f = (Get-Content \"x.tmp\")[0] Write-Host \"Inside the file: $f\"  Output: Inside the file: One<\/code><\/pre>\n<p>\u041d\u0443 \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"powershell\">@\" One \"@ | Out-File x2.tmp $f = (Get-Content \"x2.tmp\")[0] Write-Host \"Inside the file: $f\"  Output: Inside the file: O<\/code><\/pre>\n<p>\u0427\u0442\u043e, \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435? \u041a\u0443\u0434\u0430 \u0434\u0435\u043b\u0438\u0441\u044c &#8216;ne&#8217;? \u041e\u0442\u0432\u0435\u0442 \u0448\u043e\u043a\u0438\u0440\u0443\u0435\u0442:<\/p>\n<pre><code class=\"powershell\">(Get-Content \"x.tmp\").GetType() (Get-Content \"x2.tmp\").GetType()  IsPublic IsSerial Name                                     BaseType -------- -------- ----                                     -------- True     True     Object[]                                 System.Array True     True     String                                   System.Object<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0437 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u0442\u043e \u0437\u0430\u0447\u0435\u043c \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c \u0441\u043a\u043e\u0431\u043a\u0438 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u041f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0432 notepad, \u0447\u0442\u043e <em>string<\/em>, <em>string&lt;br><\/em> \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0430 \u0432\u043e\u0442 <em>string&lt;br>&lt;br><\/em> \u0438\u043b\u0438 <em>string&lt;br>&lt;sp><\/em> \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b &#8212; \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 notepad \u0432\u0441\u0435 \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0442\u043b\u0438\u0447\u0438\u043c\u044b \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430!<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"powershell\">$f = Get-Content \"x.tmp\" if ($f.GetType().Name -eq \"Object[]\") {   $firstln = $f[0] } else {   $firstln = $f } Write-Host $firstln<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e? \u041d\u0435\u0442! \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0443\u0441\u0442\u0430 (\u0442\u0430\u043c \u043d\u0435\u0442 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u0430), \u0442\u043e <em>Get-Content<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>$null<\/em>! \u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.management\/get-content?view=powershell-7.3\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Microsoft<\/a> \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u042d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u0441 \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"powershell\">$found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select * from sysdatabases\" $found.getType() $found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select top 1 * from sysdatabases\" $found.getType() $found = invoke-Sqlcmd -ServerInstance \"Localhost\" -Query \"select top 0 * from sysdatabases\" $found.getType()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0432 \u043a\u043e\u0434\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"powershell\">$cnt = $found.Rows.Count if ($found.getType().FullName -eq 'System.Management.Automation.PSCustomObject')    { $cnt = 1; }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b <strong>Python<\/strong> \u0441 \u0437\u0430\u0432\u0438\u0441\u0442\u044c\u044e \u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0435\u0440\u0432\u043d\u043e \u043a\u0443\u0440\u044f\u0442 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u043a\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u043b\u0438\u0448\u0435\u043d\u044b \u044d\u0441\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u043e\u0448\u043b\u0430 \u0437\u0440\u044f.<\/p>\n<p>\u0413\u0434\u0435-\u0442\u043e \u043f\u043b\u0430\u0447\u0443\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438 \u043e\u0434\u043d\u043e\u0433\u043e, \u0438 \u043d\u0443\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0434\u043d\u043e\u0433\u043e &#171;\u0442\u0438\u043f\u0430&#187;. \u041d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 <strong>PowerShell<\/strong> \u043f\u043e\u0445\u043e\u0436\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u0432 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0435: <em>\u043d\u043e\u043b\u044c, \u043e\u0434\u0438\u043d, \u043c\u043d\u043e\u0433\u043e<\/em>.<\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0441\u0442\u0440\u0435\u043b<\/h2>\n<p>\u0412\u0430\u043c \u0435\u0449\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 <strong>PowerShell<\/strong>? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u044d\u0442\u043e\u043c. \u0412\u043e\u0442 \u0435\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"powershell\">function something([string]$file, [string]$p2)   {   New-item $file   return \"always OK\" }  $res = something \"xxx.tmp\" \"beta\" Write-host \"Result: $res\" $res.GetType()<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 <strong>$res<\/strong>? \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a\u043e\u0433\u043e \u0447\u0435\u0440\u0442\u0430? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 <strong>PowerShell<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 <em>return<\/em> (\u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c), \u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0445\u043e\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412\u044b\u0432\u043e\u0434 <em>new-Item<\/em> \u043f\u0440\u0438\u043b\u0435\u043f\u0438\u043b\u0441\u044f \u0434\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0432\u0435\u043b\u0438 \u0432 <em>return<\/em>. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u0434\u043e\u043f\u0438\u0441\u0430\u0432 <em>| Out-Null<\/em> \u043f\u043e\u0441\u043b\u0435 <em>New-Item<\/em>, \u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0412\u0430\u0441\u0435\u0439 \u041f\u0443\u043f\u043a\u0438\u043d\u044b\u043c, <em>\u0432\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/em>. <em>\u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0438-\u0447\u0435-\u0433\u043e.<\/em><\/p>\n<p>\u041f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0438 \u0432 \u0441\u0432\u043e\u0435\u043c <a href=\"https:\/\/www.actionatdistance.com\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a> \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430 <strong>PowerShell<\/strong>. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043c\u0430\u0445\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 <strong>Ubuntu<\/strong> \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/mssql\" rel=\"noopener noreferrer nofollow\"><strong>MSSQL<\/strong><\/a>, <a href=\"https:\/\/www.actionatdistance.com\/postgres\" rel=\"noopener noreferrer nofollow\"><strong>Postgre<\/strong><\/a> \u0438 <a href=\"https:\/\/www.actionatdistance.com\/mysql\" rel=\"noopener noreferrer nofollow\"><strong>MySQL<\/strong><\/a> \u0441 <strong>PowerShell<\/strong> \u043d\u0430 <strong>Python<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043f\u043e\u0434 <strong>Ubuntu<\/strong>, \u044f \u043d\u0435 \u043c\u043e\u0433 \u0443\u0436\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b <strong>pwsh<\/strong> \u0434\u043b\u044f <strong>Ubuntu<\/strong> \u0438 \u0443\u0431\u0435\u0434\u0438\u043b\u0441\u044f, \u0447\u0442\u043e <strong>PowerShell<\/strong> \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0434\u0430\u0436\u0435 \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u0432\u0441\u0435 case-insensitive. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b <strong>Python<\/strong>-\u0432\u0435\u0440\u0441\u0438\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043f\u043e\u0434 <strong>Windows<\/strong> \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u0443\u0441\u043f\u043e\u043a\u043e\u0438\u043b <em>\u0435\u0435 \u0432\u0435\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/em>. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, <strong>Python<\/strong> \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0435\u0437\u0434\u0435 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. <strong>PowerShell<\/strong> \u0442\u0443\u043f\u0438\u0442 \u0434\u043e\u043b\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 GUI \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/723730\/\"> https:\/\/habr.com\/ru\/post\/723730\/<\/a><br \/><\/br><\/br><\/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-347069","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347069","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=347069"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347069\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}