{"id":10,"date":"2016-01-30T15:54:13","date_gmt":"2016-01-30T14:54:13","guid":{"rendered":"http:\/\/fomas.be\/blog\/?p=10"},"modified":"2016-02-01T11:21:04","modified_gmt":"2016-02-01T10:21:04","slug":"secure-connection-to-exchange-2013-with-powershell","status":"publish","type":"post","link":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/","title":{"rendered":"Secure connection to Exchange 2013 with Powershell"},"content":{"rendered":"<!-- google_ad_section_start --><p><strong>Summary:<\/strong><\/p>\n<p>Using Powershell to make a secure connection to Exchange. Why? Because no password should be stored plain text, ANYWHERE!<\/p>\n<p><strong>Versions:<\/strong><\/p>\n<p>Powershell: 4.0 or greater<\/p>\n<p>Exchange: 2013<\/p>\n<p><strong>Instructions:<\/strong><\/p>\n<p>First you have to create a secure string from the password of an account. This should be done on the server\/workstation that will make the connection in the future. Do this by executing:<\/p>\n<p><!--more--><\/p>\n<blockquote><p>read-host -assecurestring | convertfrom-securestring | out-file C:\\temp\\Cred\\securestring.txt<\/p><\/blockquote>\n<p>As a result, you should get a file called &#8216;securestring.txt&#8217; on the location specified. Please open it for verification:<\/p>\n<ul>\n<li>You will not be able to see your password.<\/li>\n<li>The file actually has content.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Next chunck of code is used for connecting to the Exchange using the secured file made in the previous step.<\/p>\n<blockquote>\n<p style=\"text-align: left;\">$ExchangeServerUrl = &#8220;http:\/\/exchangeserver.domain.local\/powershell\/&#8221;<\/p>\n<p style=\"text-align: left;\">#Build EXChange Remote Secure Connection<br \/>\n#Build $cred variabele using secure password file<\/p>\n<p style=\"text-align: left;\">$username = &#8220;Domain\\ServiceAccount&#8221;<br \/>\n$password = cat C:\\temp\\Cred\\securestring.txt | convertto-securestring<br \/>\n$cred = new-object -typename System.Management.Automation.PSCredential `<br \/>\n-argumentlist $username, $password<\/p>\n<p style=\"text-align: left;\">#Build and import secure session to Exchange 2013 on ExchangeServer using $cred credentials<br \/>\n#Now Exchange CMDlets can be used as if it concerns an Exchange Posh session<br \/>\n$session = new-pssession -configurationname MIcrosoft.eXchange -connectionuri $ExchangeServerUrl -authentication kerberos -credential $cred<br \/>\nImport-PSSession $Session<\/p>\n<\/blockquote>\n<p>You are now connected to your Exchange server using Powershell. This allows you to perform various Exchange tasks from Powershell without opening the Exchange Console:<\/p>\n<ul>\n<li>Enable-MailUser<\/li>\n<li>Set-MailUser<\/li>\n<li>Get-MailUser<\/li>\n<li>Get-MailContact<\/li>\n<li>&#8230;.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>When done, don&#8217;t forget you should clear your object from memory (should be done\u00a0with any object):<\/p>\n<blockquote>\n<p style=\"text-align: left;\">Remove-PSSession $Session<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<!-- google_ad_section_end -->","protected":false},"excerpt":{"rendered":"<p>Summary: Using Powershell to make a secure connection to Exchange. Why? Because no password should be stored plain text, ANYWHERE! Versions: Powershell: 4.0 or greater Exchange: 2013 Instructions: First you have to create a secure string from the password of an account. This should be done on the server\/workstation that will make the connection in&hellip;<a href=\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\">Read more <span class=\"screen-reader-text\">Secure connection to Exchange 2013 with Powershell<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[4,3],"tags":[],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Secure connection to Exchange 2013 with Powershell - @F0mix<\/title>\n<meta name=\"description\" content=\"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Secure connection to Exchange 2013 with Powershell - @F0mix\" \/>\n<meta property=\"og:description\" content=\"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script\" \/>\n<meta property=\"og:url\" content=\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"@F0mix\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-30T14:54:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-02-01T10:21:04+00:00\" \/>\n<meta name=\"author\" content=\"fomas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"fomas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\",\"url\":\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\",\"name\":\"Secure connection to Exchange 2013 with Powershell - @F0mix\",\"isPartOf\":{\"@id\":\"http:\/\/fomas.be\/blog\/#website\"},\"datePublished\":\"2016-01-30T14:54:13+00:00\",\"dateModified\":\"2016-02-01T10:21:04+00:00\",\"author\":{\"@id\":\"http:\/\/fomas.be\/blog\/#\/schema\/person\/d25a64d374776dd775ddf2827081d52b\"},\"description\":\"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script\",\"breadcrumb\":{\"@id\":\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/fomas.be\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Secure connection to Exchange 2013 with Powershell\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/fomas.be\/blog\/#website\",\"url\":\"http:\/\/fomas.be\/blog\/\",\"name\":\"@F0mix\",\"description\":\"Passion for SQL and POSH\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/fomas.be\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/fomas.be\/blog\/#\/schema\/person\/d25a64d374776dd775ddf2827081d52b\",\"name\":\"fomas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/fomas.be\/blog\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/52f3d103e5bf09db931859e978d97df9?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/52f3d103e5bf09db931859e978d97df9?s=96&d=mm&r=g\",\"caption\":\"fomas\"},\"url\":\"http:\/\/fomas.be\/blog\/author\/fomas\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Secure connection to Exchange 2013 with Powershell - @F0mix","description":"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Secure connection to Exchange 2013 with Powershell - @F0mix","og_description":"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script","og_url":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/","og_site_name":"@F0mix","article_published_time":"2016-01-30T14:54:13+00:00","article_modified_time":"2016-02-01T10:21:04+00:00","author":"fomas","twitter_card":"summary_large_image","twitter_misc":{"Written by":"fomas","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/","url":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/","name":"Secure connection to Exchange 2013 with Powershell - @F0mix","isPartOf":{"@id":"http:\/\/fomas.be\/blog\/#website"},"datePublished":"2016-01-30T14:54:13+00:00","dateModified":"2016-02-01T10:21:04+00:00","author":{"@id":"http:\/\/fomas.be\/blog\/#\/schema\/person\/d25a64d374776dd775ddf2827081d52b"},"description":"Make a secure connection to Exchange 2013 with Powershell for performing tasks from a Powershell script","breadcrumb":{"@id":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/fomas.be\/blog\/2016\/01\/30\/secure-connection-to-exchange-2013-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/fomas.be\/blog\/"},{"@type":"ListItem","position":2,"name":"Secure connection to Exchange 2013 with Powershell"}]},{"@type":"WebSite","@id":"http:\/\/fomas.be\/blog\/#website","url":"http:\/\/fomas.be\/blog\/","name":"@F0mix","description":"Passion for SQL and POSH","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/fomas.be\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/fomas.be\/blog\/#\/schema\/person\/d25a64d374776dd775ddf2827081d52b","name":"fomas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/fomas.be\/blog\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/52f3d103e5bf09db931859e978d97df9?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/52f3d103e5bf09db931859e978d97df9?s=96&d=mm&r=g","caption":"fomas"},"url":"http:\/\/fomas.be\/blog\/author\/fomas\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7bTMw-a","jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/posts\/10"}],"collection":[{"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":2,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":18,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/posts\/10\/revisions\/18"}],"wp:attachment":[{"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fomas.be\/blog\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}