{"id":3376,"date":"2018-02-09T11:48:16","date_gmt":"2018-02-09T08:48:16","guid":{"rendered":"https:\/\/www.buldakov.ru\/?p=3376"},"modified":"2018-02-09T11:48:16","modified_gmt":"2018-02-09T08:48:16","slug":"dsc-%d0%bd%d0%b5%d1%81%d0%be%d0%b2%d0%bc%d0%b5%d1%81%d1%82%d0%b8%d0%bc%d0%be%d1%81%d1%82%d1%8c-%d0%b2-%d1%80%d0%b0%d0%b7%d0%bd%d1%8b%d1%85-%d0%b2%d0%b5%d1%80%d1%81%d0%b8%d1%8f%d1%85-%d1%84%d1%80","status":"publish","type":"post","link":"https:\/\/www.buldakov.ru\/?p=3376","title":{"rendered":"DSC: \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432"},"content":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Exchange \u0447\u0435\u0440\u0435\u0437 DSC.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u0430\u043c\u0438 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f DSC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f xExchange. \u041c\u043e\u0434\u0443\u043b\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 WinRM \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 Exchange. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u0442\u0430\u0442\u044c \u0433\u0435\u0440\u043e\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0431\u0430\u0435\u043a \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0431\u043b\u0430\u0433\u043e DSC \u0434\u0430\u0451\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u0435\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0421\u0445\u0435\u043c\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/powershell\/dsc\/secureMOF\">\u0442\u0443\u0442<\/a>. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 Exchange \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 Windows Server 2012 R2 (\u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 &#8211; 2013 \u0438\u043b\u0438 2016) \u044d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0447\u0435\u043c\u0443.<\/p>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 PSDesiredStateConfiguration \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0Get-EncryptedPassword. \u041f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 PSDesiredStateConfiguration.psm1. \u0412 \u043a\u0440\u0430\u0442\u0446\u0435, \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f DSC \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 WMF 4.0, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0434\u0451\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0441 Windows Server 2012 R2 (\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 Windows Server 2012 R2\/Exchange 2013\/16) \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\"># Cast the public key correctly\r\n$rsaProvider = &#x5B;System.Security.Cryptography.RSACryptoServiceProvider]$cert.PublicKey.Key\r\n\r\n# Convert to a byte array\r\n$keybytes = &#x5B;System.Text.Encoding]::UNICODE.GetBytes($value)\r\n\r\n# Add a null terminator to the byte array\r\n$keybytes += 0\r\n$keybytes += 0\r\n\r\n# Encrypt using the public key\r\n$encbytes = $rsaProvider.Encrypt($keybytes, $false)\r\n\r\n# Reverse bytes for unmanaged decryption\r\n&#x5B;Array]::Reverse($encbytes)\r\n\r\n# Return a string\r\n&#x5B;Convert]::ToBase64String($encbytes)<\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 DSC, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0434\u0451\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0441 WMF 5.0\/5.1:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\"># Encrypt using the public key\r\n$encMsg =Protect-CmsMessage -To $CmsMessageRecipient -Content $Value\r\n\r\n# Reverse bytes for unmanaged decryption\r\n#&#x5B;Array]::Reverse($encbytes)\r\n\r\n#$encMsg = $encMsg -replace '-----BEGIN CMS-----',''\r\n#$encMsg = $encMsg -replace &quot;`n&quot;,''\r\n#$encMsg = $encMsg -replace '-----END CMS-----',''\r\n\r\nreturn $encMsg<\/pre>\n<p>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 10 \u043e\u0442\u043b\u0438\u0447\u0438\u0439. \u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e mof-\u0444\u0430\u0439\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Windows Server 2016 (WMF 5.1) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0430\u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c DSC \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0434\u0451\u0442 \u0441 WMF 4.0 \u043d\u0430 Windows Server 2012 R2.<\/p>\n<p><span style=\"text-decoration: underline;\">\u0412\u044b\u0432\u043e\u0434<\/span>: \u0432\u0441\u0435 mof-\u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Exchange \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 Windows Server 2012 R2 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435\u00a0Windows Server 2012 R2 \u0441 \u0438\u0434\u0443\u0449\u0438\u043c \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c\u00a0WMF 4.0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Exchange \u0447\u0435\u0440\u0435\u0437 DSC. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u0430\u043c\u0438 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f DSC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f xExchange. \u041c\u043e\u0434\u0443\u043b\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 WinRM \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 Exchange. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u0442\u0430\u0442\u044c \u0433\u0435\u0440\u043e\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0431\u0430\u0435\u043a \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0431\u043b\u0430\u0433\u043e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7,11],"tags":[],"class_list":["post-3376","post","type-post","status-publish","format-standard","hentry","category-exchange","category-powershell","category-life"],"_links":{"self":[{"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/posts\/3376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3376"}],"version-history":[{"count":2,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/posts\/3376\/revisions"}],"predecessor-version":[{"id":3378,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=\/wp\/v2\/posts\/3376\/revisions\/3378"}],"wp:attachment":[{"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buldakov.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}