{"id":10091,"date":"2017-06-22T14:38:39","date_gmt":"2017-06-22T13:38:39","guid":{"rendered":"https:\/\/myworldofit.net\/?p=10091"},"modified":"2017-09-13T09:57:27","modified_gmt":"2017-09-13T08:57:27","slug":"managing-sympa-mailing-lists-with-powershell-v1-0","status":"publish","type":"post","link":"https:\/\/myworldofit.net\/?p=10091","title":{"rendered":"Managing Sympa (Mailing Lists) with PowerShell (v1.0)"},"content":{"rendered":"<p>If you are running (or use) the <a href=\"https:\/\/www.sympa.org\/\">Sympa<\/a> Mailing List but also use Windows PowerShell then you may want to be aware of <a href=\"https:\/\/github.com\/jamesfed\/PSSympa\">PSSympa<\/a> which recently went v1.0 on <a href=\"https:\/\/github.com\/jamesfed\/PSSympa\">GitHub<\/a> and the <a href=\"https:\/\/www.powershellgallery.com\/packages\/PSSympa\">PowerShell Gallery<\/a>.<\/p>\n<p>In this release we have\u2026<\/p>\n<h2>Functions<\/h2>\n<ul>\n<li>Get-SympaLogin (to login and get a session cookie \u2013 the result of which is used with all other functions)<\/li>\n<li>Get-SympaMailingListMember (get the members of a list or list(s))<\/li>\n<li>Add-SympaMailingListMember (add a member(s) to a list)<\/li>\n<li>Remove-SympaMailingListMember (removes a member(s) from a list)<\/li>\n<li>Test-SympaMailingListMember (checks to see if someone is a Subscriber, Owner or Editor of a list)<\/li>\n<li>Sync-SympaMailingList (based on the contents of a reference CSV makes changes to the membership of a list)<\/li>\n<\/ul>\n<h2>Samples<\/h2>\n<ul>\n<li>How a CSV storing credentials might look (samplecredsfile.csv)<\/li>\n<li>How a CSV that is used to Add\/Remove members in bulk to\/from a single list (samplememberslist.csv)<\/li>\n<li>How a CSV that is used with the Sync- function would look (samplesynclist.csv)<\/li>\n<\/ul>\n<h2>Super Awesome Features<\/h2>\n<ul>\n<li>Credentials can be stored in a CSV to avoid them being typed in as part of a wider script<\/li>\n<li>Pipeline support for members in lists<\/li>\n<\/ul>\n<h2>How to get it<\/h2>\n<p>The PowerShell Gallery is the best route to get your hands on the Module, see this link &#8211;&nbsp;<a href=\"https:\/\/www.powershellgallery.com\/packages\/PSSympa\">https:\/\/www.powershellgallery.com\/packages\/PSSympa<\/a> for the full details in short though you should only need to run the following command at your PowerShell prompt (assuming you are running a recent version of PowerShell) to install the module on your PC.<\/p>\n<blockquote><p>Install-Module -Name PSSympa<\/p><\/blockquote>\n<p><!--more--><\/p>\n<h2>Example usage<\/h2>\n<p>#Login<br \/>\n$Sympa = Get-SympaLogin -Username test-user@ox.ac.uk -Password $(&#8220;cheesypassword1&#8221; | ConvertTo-SecureString&nbsp;-AsPlainText&nbsp;-Force) -WSDL https:\/\/web.maillist.ox.ac.uk\/ox\/wsdl<\/p>\n<p>#Get a list of members<br \/>\nGet-SympaMailingListMember -Sympa $Sympa -MailingList queens-it<\/p>\n<p>#Get a list of members and send the list to a CSV<br \/>\nGet-SympaMailingListMember -Sympa $Sympa -MailingList queens-it | Export-Csv C:\\Temp\\list.csv \u2013NoTypeInformation<\/p>\n<p>#Add a member to a mailing list<br \/>\nAdd-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member jim.bob@queens.ox.ac.uk<br \/>\nOr<br \/>\nAdd-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member @(&#8216;jim.bob@queens.ox.ac.uk&#8217;,&#8217;jim.kirk@queens.ox.ac.uk&#8217;)<\/p>\n<p>#Remove a member from a mailing list<br \/>\nRemove-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member jim.bob@queens.ox.ac.uk<br \/>\nOr<br \/>\nRemove-SympaMailingListMember -Sympa $Sympa -MailingList queens-it -Member @(&#8216;jim.bob@queens.ox.ac.uk&#8217;,&#8217;jim.kirk@queens.ox.ac.uk&#8217;)<\/p>\n<p>#Sync up a set of lists in Sympa with a CSV<br \/>\nSync-SympaMailingList -Sympa $Sympa -Path C:\\Sympa\\synclist.csv<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are running (or use) the Sympa Mailing List but also use Windows PowerShell then you may want to be aware of PSSympa which recently went v1.0 on GitHub and the PowerShell Gallery. In this release we have\u2026 Functions Get-SympaLogin (to login and get a session cookie \u2013 the result of which is used with all other functions) Get-SympaMailingListMember&#8230; <a class=\"read-more\" href=\"https:\/\/myworldofit.net\/?p=10091\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[20],"tags":[403,401,248,402,400],"series":[],"class_list":["post-10091","post","type-post","status-publish","format-standard","hentry","category-software","tag-github","tag-mailing-list","tag-powershell","tag-powershell-gallery","tag-sympa"],"_links":{"self":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/10091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10091"}],"version-history":[{"count":6,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/10091\/revisions"}],"predecessor-version":[{"id":10462,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/10091\/revisions\/10462"}],"wp:attachment":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10091"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=10091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}