Blog

27 Aug 2012 by emma.robinson

POP Mailbox using Powershell

This function accesses a mailbox using POP3 and returns various bits of information including the number of messages and the size of the inbox. ############################################################################### # Function POP3User # # POP’s the users mailbox and returns the size of the Inbox in Bytes # # Pass the POP Server IP, Username and Password ############################################################################### function […]

8 Aug 2012 by emma.robinson

Parsing JSON in PowerShell, XML & The member "Item" is already present

I came across an annoying Powershell bug recently whilst working on a project to parse JSON data from the web in Powershell. I was working with the following script Add-Type -Assembly System.ServiceModel.Web,System.Runtime.Serialization function Convert-JsonToXml([string]$json) { $bytes = [byte[]][char[]]$json $quotas = [System.Xml.XmlDictionaryReaderQuotas]::Max $jsonReader = [System.Runtime.Serialization.Json.JsonReaderWriterFactory]::CreateJsonReader($bytes,$quotas) try { $xml = new-object System.Xml.XmlDocument $xml.Load($jsonReader) $xml } finally { […]