<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>mailstore-notes.dwlab.me - PowerShell</title>
    <link rel="self" type="application/atom+xml" href="https://mailstore-notes.dwlab.me/tags/powershell/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://mailstore-notes.dwlab.me/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2023-01-01T00:00:00+00:00</updated>
    <id>https://mailstore-notes.dwlab.me/tags/powershell/atom.xml</id>
    <entry xml:lang="en">
        <title>Getting started with MailStore SPE&#x27;s Management API</title>
        <published>2023-01-01T00:00:00+00:00</published>
        <updated>2023-01-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              dave
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://mailstore-notes.dwlab.me/articles/getting-started-with-mailstore-spe-s-management-api/"/>
        <id>https://mailstore-notes.dwlab.me/articles/getting-started-with-mailstore-spe-s-management-api/</id>
        
        <content type="html" xml:base="https://mailstore-notes.dwlab.me/articles/getting-started-with-mailstore-spe-s-management-api/">&lt;h2 id=&quot;enable-the-api&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#enable-the-api&quot; aria-label=&quot;Anchor link for: enable-the-api&quot;&gt;🔗&lt;&#x2F;a&gt;Enable the API&lt;&#x2F;h2&gt;
&lt;p&gt;The API might already be enabled, but let&#x27;s check that it is enabled before proceeding:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Launch the &lt;em&gt;MailStore Service Provider Edition Configuration&lt;&#x2F;em&gt; tool.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Stop the &lt;em&gt;Management Server&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;em&gt;Configure...&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Ensure &lt;em&gt;API HTTP Server Enabled&lt;&#x2F;em&gt; is checked.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Set &lt;em&gt;Listeners&lt;&#x2F;em&gt; to &lt;code&gt;*:8474&lt;&#x2F;code&gt; (without the quotes).&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Copy the &lt;em&gt;Certificate&lt;&#x2F;em&gt; field from &lt;strong&gt;Management Server Settings&lt;&#x2F;strong&gt; and paste it in to the &lt;em&gt;Server Certificate&lt;&#x2F;em&gt; field in the API section.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;em&gt;OK&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Start&lt;&#x2F;em&gt; the &lt;em&gt;Management Service&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;using-the-powershell-wrapper&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#using-the-powershell-wrapper&quot; aria-label=&quot;Anchor link for: using-the-powershell-wrapper&quot;&gt;🔗&lt;&#x2F;a&gt;Using the PowerShell wrapper&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;wrapper-and-sample-code&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#wrapper-and-sample-code&quot; aria-label=&quot;Anchor link for: wrapper-and-sample-code&quot;&gt;🔗&lt;&#x2F;a&gt;Wrapper and sample code&lt;&#x2F;h2&gt;
&lt;p&gt;Referring to the PowerShell API Wrapper and sample code found in: &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;PowerShell_API_Wrapper_Tutorial&quot;&gt;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;PowerShell_API_Wrapper_Tutorial&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;set-executionpolicy-to-run-downloaded-scripts&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#set-executionpolicy-to-run-downloaded-scripts&quot; aria-label=&quot;Anchor link for: set-executionpolicy-to-run-downloaded-scripts&quot;&gt;🔗&lt;&#x2F;a&gt;Set-ExecutionPolicy to run downloaded scripts&lt;&#x2F;h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Launch PowerShell as administrator&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Run &lt;code&gt;Set-ExecutionPolicy -ExecutionPolicy Unrestricted&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;make-our-first-api-call&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#make-our-first-api-call&quot; aria-label=&quot;Anchor link for: make-our-first-api-call&quot;&gt;🔗&lt;&#x2F;a&gt;Make our first API call&lt;&#x2F;h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download &lt;em&gt;MailStore PowerShell API Wrapper and tutorial example scripts&lt;&#x2F;em&gt; from &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;images&#x2F;1&#x2F;19&#x2F;MailStore_SPE_Scripting_Tutorial.zip&quot;&gt;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;images&#x2F;1&#x2F;19&#x2F;MailStore_SPE_Scripting_Tutorial.zip&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Unzip &lt;code&gt;MailStore_SPE_Scripting_Tutorial.zip&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Open the &lt;code&gt;MailStore SPE Scripting Tutorial\PowerShell\Scripts&lt;&#x2F;code&gt; directory.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Edit &lt;em&gt;Example1.ps1&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Set the username&#x2F;password.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Adjust the managementserver and port (if needed). If you&#x27;re working on the management server itself then the defaults should be fine.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Run &lt;code&gt;.\Example1.ps1&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The result I get is:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;error           :
token           :
statusVersion   : 2
statusCode      : succeeded
percentProgress :
statusText      :
result          : @{version=22.4.0.21151; webClientVersion=22.4.0.21151; copyright=Copyright (c) 2005-2022 MailStore
                  Software GmbH; licenseeName=ehemaliger Testaccount; licenseeID=10510;
                  serverName=spe-server.example.com; username=admin; systemProperties=}
logOutput       :
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;Example2.ps&lt;&#x2F;em&gt; shows how to pass parameters using &lt;code&gt;&quot;GetInstances&quot; @{instanceFilter = &quot;*&quot;}&lt;&#x2F;code&gt;, and then it pulls the users from within each instance as an example of how to repeat an operation through different instances. It should just be a matter of updating the connection string in this script with your servername and credentials.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;call-the-https-api-directly&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#call-the-https-api-directly&quot; aria-label=&quot;Anchor link for: call-the-https-api-directly&quot;&gt;🔗&lt;&#x2F;a&gt;Call the HTTPS API directly&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;install-a-browser-extension&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#install-a-browser-extension&quot; aria-label=&quot;Anchor link for: install-a-browser-extension&quot;&gt;🔗&lt;&#x2F;a&gt;Install a browser extension&lt;&#x2F;h3&gt;
&lt;p&gt;I&#x27;m using RESTClient (Firefox-based extension to make API calls interactively from a browser): &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;addons.mozilla.org&#x2F;en-US&#x2F;firefox&#x2F;addon&#x2F;restclient&#x2F;&quot;&gt;https:&#x2F;&#x2F;addons.mozilla.org&#x2F;en-US&#x2F;firefox&#x2F;addon&#x2F;restclient&#x2F;&lt;&#x2F;a&gt; but other tools should be fine.&lt;&#x2F;p&gt;
&lt;p&gt;For reference my server&#x27;s API is available at:
&lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;spe-server.example.com:8474&quot;&gt;https:&#x2F;&#x2F;spe-server.example.com:8474&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;trust-the-certificate&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#trust-the-certificate&quot; aria-label=&quot;Anchor link for: trust-the-certificate&quot;&gt;🔗&lt;&#x2F;a&gt;Trust the certificate&lt;&#x2F;h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First access the URI and allow the untrusted certificate (if needed)&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Do this by visiting &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;spe-server.example.com:8474&#x2F;&quot;&gt;https:&#x2F;&#x2F;spe-server.example.com:8474&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Advanced -&amp;gt; Accept the certificate&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Close the tab when prompted for credentials.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;make-a-first-call-to-the-api&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#make-a-first-call-to-the-api&quot; aria-label=&quot;Anchor link for: make-a-first-call-to-the-api&quot;&gt;🔗&lt;&#x2F;a&gt;Make a first call to the API&lt;&#x2F;h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Now launch RESTClient&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Click the Authentication tab&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Set the admin username&#x2F;password.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Change the &lt;strong&gt;Method&lt;&#x2F;strong&gt; to &lt;em&gt;Post&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Call &lt;code&gt;https:&#x2F;&#x2F;spe-server.example.com:8474&#x2F;api&#x2F;invoke&#x2F;GetInstanceHosts&lt;&#x2F;code&gt; (without the quotes)&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;My response looks like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;{
  &amp;quot;error&amp;quot;: null,
  &amp;quot;token&amp;quot;: null,
  &amp;quot;statusVersion&amp;quot;: 2,
  &amp;quot;statusCode&amp;quot;: &amp;quot;succeeded&amp;quot;,
  &amp;quot;percentProgress&amp;quot;: null,
  &amp;quot;statusText&amp;quot;: null,
  &amp;quot;result&amp;quot;: [
    {
      &amp;quot;serverName&amp;quot;: &amp;quot;spe-server.example.com&amp;quot;,
      &amp;quot;port&amp;quot;: 8472,
      &amp;quot;serverCertificate&amp;quot;: {
        &amp;quot;thumbprint&amp;quot;: &amp;quot;A61597D8316DC39E26466F22C4C42B0C824ABE12&amp;quot;
      },
      &amp;quot;baseDirectory&amp;quot;: null
    }
  ],
  &amp;quot;logOutput&amp;quot;: null
}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I used this API method because we can now add a body to test.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;add-parameters-to-apply-a-filter&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#add-parameters-to-apply-a-filter&quot; aria-label=&quot;Anchor link for: add-parameters-to-apply-a-filter&quot;&gt;🔗&lt;&#x2F;a&gt;Add parameters to apply a filter&lt;&#x2F;h3&gt;
&lt;p&gt;I&#x27;ll add the body &lt;code&gt;serverNameFilter=doesnotexist&lt;&#x2F;code&gt; (again, without the quotes) and we see no errors, but also no servers were returned, so we know the server accepted the parameter as the behaviour changed from above:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;{
  &amp;quot;error&amp;quot;: null,
  &amp;quot;token&amp;quot;: null,
  &amp;quot;statusVersion&amp;quot;: 2,
  &amp;quot;statusCode&amp;quot;: &amp;quot;succeeded&amp;quot;,
  &amp;quot;percentProgress&amp;quot;: null,
  &amp;quot;statusText&amp;quot;: null,
  &amp;quot;result&amp;quot;: [],
  &amp;quot;logOutput&amp;quot;: null
}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And now I&#x27;ll change the body to:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;serverNameFilter=spe-server.example.com&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Now we get the requested server again, confirming everything is working:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;{
  &amp;quot;error&amp;quot;: null,
  &amp;quot;token&amp;quot;: null,
  &amp;quot;statusVersion&amp;quot;: 2,
  &amp;quot;statusCode&amp;quot;: &amp;quot;succeeded&amp;quot;,
  &amp;quot;percentProgress&amp;quot;: null,
  &amp;quot;statusText&amp;quot;: null,
  &amp;quot;result&amp;quot;: [
    {
      &amp;quot;serverName&amp;quot;: &amp;quot;spe-server.example.com&amp;quot;,
      &amp;quot;port&amp;quot;: 8472,
      &amp;quot;serverCertificate&amp;quot;: {
        &amp;quot;thumbprint&amp;quot;: &amp;quot;A61597D8316DC39E26466F22C4C42B0C824ABE12&amp;quot;
      },
      &amp;quot;baseDirectory&amp;quot;: null
    }
  ],
  &amp;quot;logOutput&amp;quot;: null
}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;make-a-more-complex-api-call&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#make-a-more-complex-api-call&quot; aria-label=&quot;Anchor link for: make-a-more-complex-api-call&quot;&gt;🔗&lt;&#x2F;a&gt;Make a more complex API call&lt;&#x2F;h3&gt;
&lt;p&gt;Use &lt;em&gt;CreateSystemAdministrator&lt;&#x2F;em&gt; &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;Management_API_-_Function_Reference#CreateSystemAdministrator&quot;&gt;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;spe&#x2F;Management_API_-_Function_Reference#CreateSystemAdministrator&lt;&#x2F;a&gt; to create a new system administrator. I selected this example because we need both a &lt;em&gt;json&lt;&#x2F;em&gt; parameter, and a second parameter that is not part of the &lt;em&gt;json&lt;&#x2F;em&gt; block.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Change the URI to:
&lt;code&gt;https:&#x2F;&#x2F;spe-server.example.com:8474&#x2F;api&#x2F;invoke&#x2F;CreateSystemAdministrator&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Change the body:
&lt;code&gt;config={  &quot;userName&quot; : &quot;bob&quot;,  &quot;fullName&quot; : &quot;Bob the Admin&quot;,  &quot;emailAddress&quot; : &quot;bob@example.com&quot;}&amp;amp;password=Passw0rd!&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Submit to the server.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The result is &quot;statusCode&quot;: &quot;succeeded&quot;&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;{
  &amp;quot;error&amp;quot;: null,
  &amp;quot;token&amp;quot;: null,
  &amp;quot;statusVersion&amp;quot;: 2,
  &amp;quot;statusCode&amp;quot;: &amp;quot;succeeded&amp;quot;,
  &amp;quot;percentProgress&amp;quot;: null,
  &amp;quot;statusText&amp;quot;: null,
  &amp;quot;result&amp;quot;: null,
  &amp;quot;logOutput&amp;quot;: null
}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And to confirm it really did work, I verified I can login with my newly created administrator &quot;bob&quot; using the management web interface *port 8470)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;curl&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#curl&quot; aria-label=&quot;Anchor link for: curl&quot;&gt;🔗&lt;&#x2F;a&gt;curl&lt;&#x2F;h2&gt;
&lt;p&gt;We could do the same from &lt;em&gt;curl&lt;&#x2F;em&gt; using this command line:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;curl -X POST -k -H &#x27;Authorization: Basic YWRtaW46UGFzc3cwcmQhIQ==&#x27; -i &#x27;https:&#x2F;&#x2F;spe-server.example.com:8474&#x2F;api&#x2F;invoke&#x2F;CreateSystemAdministrator&#x27; --data &#x27;config={  &quot;userName&quot; : &quot;joe&quot;,  &quot;fullName&quot; : &quot;Joe the Admin&quot;,  &quot;emailAddress&quot; : &quot;joe@example.com&quot;}&amp;amp;password=Passw0rd!&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Use SetUserPrivilegesOnFolder from PowerShell</title>
        <published>2023-01-01T00:00:00+00:00</published>
        <updated>2023-01-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              dave
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://mailstore-notes.dwlab.me/articles/use-setuserprivilegesonfolder-from-powershell/"/>
        <id>https://mailstore-notes.dwlab.me/articles/use-setuserprivilegesonfolder-from-powershell/</id>
        
        <content type="html" xml:base="https://mailstore-notes.dwlab.me/articles/use-setuserprivilegesonfolder-from-powershell/">&lt;p&gt;First please refer to the &lt;a class=&quot;&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;help.mailstore.com&#x2F;en&#x2F;server&#x2F;PowerShell_API_Wrapper_Tutorial&quot;&gt;MailStore PowerShell API Wrapper&lt;&#x2F;a&gt; article for instructions on the system requirements and basics of the PowerShell wrapper.&lt;&#x2F;p&gt;
&lt;p&gt;Once you have PowerShell installed and the API Wrapper downloaded, enter the commands from the documentation to load the module and establish a connection:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;Import-Module &#x27;..\API-Wrapper\MS.PS.Lib.psd1&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;$msapiclient = New-MSApiClient -Username admin -Password MyAdminPa$$W0rd -MailStoreServer localhost -Port 8463 -IgnoreInvalidSSLCerts&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;And now we can verify the connection with &lt;em&gt;GetServerInfo&lt;&#x2F;em&gt;:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;Invoke-MSApiCall $msapiclient &quot;GetServerInfo&quot; | fl&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This will only work if you are on the MailStore Server, if you are on your own workstation then update the &quot;localhost&quot; to point to the correct hostname or IP. Similarly, update the port &quot;8463&quot; if needed.&lt;&#x2F;p&gt;
&lt;p&gt;I can confirm the connection from there (including just the relevant line):&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;PS C:\&amp;gt; Invoke-MSApiCall $msapiclient &quot;GetServerInfo&quot; | fl&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;error           :
token           :
statusVersion   : 2
statusCode      : succeeded
percentProgress :
statusText      :
result          : @{version=22.3.0.21002; machineName=EXCHANGEDC}
logOutput       :
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I then used this command to pull &lt;em&gt;GetUserInfo&lt;&#x2F;em&gt;:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;(Invoke-MSApiCall $msapiclient &quot;GetUserInfo&quot; @{&quot;userName&quot; = &quot;frank.clark&quot;}).result | fl&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;username            : frank.clark
fullName            : Frank Clark
distinguishedName   : CN=Frank Clark,OU=Seattle,DC=example, DC=com
authentication      : directoryServices
emailAddresses      : {frank.clark@example.com}
pop3UserNames       : {}
privileges          : {login}
privilegesOnFolders : {@{folder=frank.clark; privileges=System.Object[]}, @{folder=abby.hernandez; privileges=System.Object[]}}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And next I added a permission:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;Invoke-MSApiCall $msapiclient &quot;SetUserPrivilegesOnFolder&quot; @{&quot;userName&quot; = &quot;frank.clark&quot;; &quot;folder&quot; = &quot;alexis.page&quot;; &quot;privileges&quot; = &quot;read&quot;}| fl&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;error           :
token           :
statusVersion   : 2
statusCode      : succeeded
percentProgress :
statusText      :
result          :
logOutput       :
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And then check the permissions again to confirm the additional permission was added:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;(Invoke-MSApiCall $msapiclient &quot;GetUserInfo&quot; @{&quot;userName&quot; = &quot;frank.clark&quot;}).result | fl&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;username            : frank.clark
fullName            : Frank Clark
distinguishedName   : CN=Frank Clark,OU=Seattle,DC=example, DC=com
authentication      : directoryServices
emailAddresses      : {frank.clark@example.com}
pop3UserNames       : {}
privileges          : {login}
privilegesOnFolders : {@{folder=frank.clark; privileges=System.Object[]}, @{folder=abby.hernandez; privileges=System.Object[]}, @{folder=alexis.page; privileges=System.Object[]}}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
</feed>
