PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Posh-SYSLOG 3.3 has been released

Several days ago, Jared raised a Pull Request for Posh-SYSLOG to correct an issue with the module’s manifest. It seems that in version 3.0 of Posh-SYSLOG, I used the PowerShellHostVersion attribute of the module manifest and not PowerShellVersion to specify the minimum Powershell version. This wouldn't have created issues within a normal PowerShell session, but would have prevented the module from loading in VS Code (as Jared reported) or the ISE.

Several days ago, Jared (powershellshock) raised a Pull Request for Posh-SYSLOG to correct an issue with the module’s manifest. It seems that in version 3.0 of Posh-SYSLOG, I used the PowerShellHostVersion attribute of the module manifest and not PowerShellVersion to specify the minimum Powershell version. This wouldn't have created issues within a normal PowerShell session, but would have prevented the module from loading in VS Code (as Jared reported) or the ISE.

To understand the difference of these attributes, I suggest reading: PowerShellHostVersion – WTF?, by Jeffrey Snover.

This is by far my most popular module and it's become even more popular this year. Since January there's been almost 20 000 downloads of the module, compared to 1600 for the previous 2 years combined! I'm amazed that this simple little module has gained such popularity!

Getting the Module

If you have never used the module before, the easiest way to get Posh-SYSLOG is through the PowerShell Gallery:

PS> Install-Module -Name Posh-SYSLOG

If you already have the module installed, you can update the module from the PowerShell Gallery with:

PS> Update-Module -Name Posh-SYSLOG

You can also find the module on GitHub.

Found an issue? Then raise any bugs or feature requests via GitHub Issues.

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

New version of AzurePublicIPAddresses module (0.8.3)

I have just released a new version of the AzurePublicIPAddress module (0.8.) to the PowerShell Gallery.

There are no major changes, just the additional support for the new Korea Regions:

  • Korea South
  • Korea Central

You can get the module from:

Kieran Jacobsen

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

New version of AzurePublicIPAddresses module (0.8.2)

I have just released a new version of the AzurePublicIPAddress module to the PowerShell Gallery.

There are no major changes, just the additional support for two new US Regions:

  • Central US EUAP
  • East US 2 EUAP

I cannot see much documentation on what these new regions are, I suspect they are the US Government regions.

The only other major change is that all the Pester Tests are now enabled. Previously the UK regions did not have any values in the XML file, these are now being published correctly.

You can get the module from:

Kieran Jacobsen

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Azure China Region support for AzurePublicIPAddresses

Photo courtesy of Microsoft. https://azure.microsoft.com/en-us/regions/

Photo courtesy of Microsoft. https://azure.microsoft.com/en-us/regions/

I am happy to announce version 0.8.1 of Azure Public IP Addresses PowerShell module.

With this release, the module now supports the China North and China East Azure regions.

Microsoft’s China Azure regions are operated by 21Vianet, Microsoft publishes the IP subnets for these regions in a separate file to the other regions, Windows Azure Datacenter IP Ranges in China.

To implement this functionality, some changes have been made to the module. Important Note: these changes do not break any existing functionality and should not impact existing code.

Get-MicrosoftAzureDatacenterIPRangeFile

The switch parameter, -ChinaRegion has been added to the Get-MicrosoftAzureDatacenterIPRangeFile CMDLet. When this parameter is specified, the then China region specific file will be downloaded; if it is absent, then it will download the general region file.

Additional validation has been added to the -Path parameter. Invalid paths should no longer be accepted.

Get-MicrosoftAzureDatacenterIPRange

This function has been to support the China North and China East Regions much like adding any other region.

Changes were required for the -path parameter. When this parameter is absent, both files are automatically downloaded. When -path is present, the CMDLet will now inspect the file spectified, and generate a warning that some Azure regions will be unavailable.

One additional change has been made to this CMDLet. The -AzureRegion parameter will now accept an array containing regions. I have also added additional validation to this parameter to ensure invalid data is not passed in (via [ValidateNotNullOrEmpty()]).

I have attempted to quite throughly test the changes to this CMDLet using Pester, and have expanded the number of included tests to ensure there are no changes.

Getting the module

The module is available via the PowerShell Gallery and GitHub.

Missing Regions

Unfortunately, there is still no support for the following regions:

  • US Gov Texas
  • US Gov Virginia
  • US DoD Central
  • US DoD East
  • Germany Northeast
  • Germany Central

These regions are not included in either of the region files, nor are they in their own region. If and when they are available, I will include support for them.

It should also be noted that currently the UK West region is missing from the Microsoft Azure Datacenter IP Ranges file. I have reached out to Azure support to resolve this.

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

AzurePublicIPAddresses Version 0.7 released

I have just released a new version of my AzurePublicIPAddresses PowerShell module. With this release (version 0.7), support for the UK data centers has been introduced.

You can learn more about using the module from my blog post, Working with Azure’s public IP addresses. James Bannan has put together a post, Update User Defined Routes for Azure Datacenters with Azure Automation, where he talks about updating user defined routes using the information from my module.

The module can be obtained via the PowerShell Gallery or from GitHub.

Kieran Jacobsen

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Posh-CloudFlare managing CloudFlare using PowerShell

The aim of the Posh-CloudFlare module is to simply and automate the management of CloudFlare hosted DNS zones using PowerShell and the CloudFlare Client API. I have made the module available via the PoshSecurity GitHub, here Posh-CloudFlare.

I started looking at CloudFlares API several months ago, as part of another post which I am still working on. Back then I was simply looking at the creation and deletion or records.

Things changed when I found that I needed to spend quite a bit of time working with DNS. Provisioning new infrastructure within cloud environments is something I spend a significant amount of time doing, and am actively investigating the automation of it, and as such, become interested in other parts of the API.

This module now implements all of the Client API, with 22 CMDLets in total. To simplify things, I have documented what CMDLet maps to what API call below:

CMDLets

API Actions

get-CFDNSZoneStatistics

3.1 - "stats" - Retrieve domain statistics for a given time frame

get-CFDNSZone

3.2 - "zone_load_multi" - Retrieve the list of domains

get-CFDNSRecord

3.3 - "rec_load_all" - Retrieve DNS Records of a given domain

get-CFDNSZoneStatus

3.4 - "zone_check" - Checks for active zones and returns their corresponding zids

Get-CFIPThreatScore

3.6 - "ip_lkup" - Check threat score for a given IP

get-CFDNSZoneSettings

3.7 - "zone_settings" - List all current setting values

Set-CFDNSZoneSecurityLevel

4.1 - "sec_lvl" - Set the security level

Set-CFDNSZoneCacheLevel

4.2 - "cache_lvl" - Set the cache level

Set-CFDNSZoneDevMode

4.3 - "devmode" - Toggling Development Mode

Clear-CFDNSZoneCache

4.4 - "fpurge_ts" -- Clear CloudFlare's cache

Clear-CFDNSZoneFileCache

4.5 - "zone_file_purge" -- Purge a single file in CloudFlare's cache

Add-CFBlackListIP

Add-CFWhiteListIP

Remove-CFListIP

4.6 - "wl" / "ban" / "nul" -- Whitelist/Blacklist/Unlist IPs

Set-CFDNSZoneIPVersion

4.7 - "ipv46" -- Toggle IPv6 support

Set-CFDNSZoneRocketLoader

4.8 - "async" -- Set Rocket Loader

Set-CFDNSZoneMinification

4.9 - "minify" -- Set Minification

Set-CFDNSZoneMirage2

4.10 - "mirage2" -- Set Mirage2

New-CFDNSRecord

5.1 - "rec_new" -- Add a DNS record

Update-CFDNSRecord

5.2 - "rec_edit" -- Edit a DNS record

Remove-CFDNSRecord

5.3 - "rec_delete" -- Delete a DNS record

The Client API can be a little tricky at first, I have developed the CMDLets in a manner to simplify the learning curve. Typically any API call which modifies or removes a DNS record, would require a rec_id to be specified. This field can be found by querying all of the records in the zone. I have simplified things by performing the search and other API queries for you. You can still specify a rec_id if you like.

Switches and parameter validation sets have been used to simplify some of the other CMDLets, particularly those around minification, security and other zone wide settings.

Finally I have tried where possible to make good use of the Pipeline. There are still a number of areas that could be improved.

Getting Started

The first thing you will need to do, is obtain your API Token. This can be found on your Account page. You will need this, and the email address you use to sign into CloudFlare for the majority of the CMDLets. For CMDLets which modify DNS Zones or records, you will need to specify the zone as well.

To obtain the module, simply perform a git clone to your preferred module location as below:

I have included a demo script, Posh-CloudFlare-Demo.ps1 at the root level of the module, which you can run on the namespace of your choice. I recommend not using your corporate production domain. At the top of this script, simply update the API Token, Email and domain name fields as required.

You can then run the script, and see it manipulate the DNS zone. I am not responsible if this breaks production. This script shows you each CMDLet and it's output. I don't recommend simply running the script, I recommend stepping through each line so you gain more of an understanding.

Potential Uses

The automatic provisionment of cloud hosted environments is why this was developed as well as another project I will announce in the coming future. For now, I see myself working on at least one module to support the automation of Office 365 provisioning, including creating the TXT, MX and SRV required.

Warnings

Firstly, I haven’t finished up the PowerShell help – Naughty! I will work on this one as I go.

Secondly, there might be some bugs. Whilst I have tried to test the majority of the permutations of the code, I can’t be fully sure I haven’t missed something. If you find one, please feel free to contact me and I will make the required fixes, or even better, push your updates up to GitHub.


Kieran Jacobsen

Read More