function Get-ProjectMetadata {
  <#
    .SYNOPSIS
    Get metadata for a Chef Software, Inc. project
    .DESCRIPTION
    Get metadata for project
    .EXAMPLE
    iex (new-object net.webclient).downloadstring('<%= base_url %>/install.ps1'); Get-ProjectMetadata -project chef -channel stable

    Gets the download url and SHA256 checksum for the latest stable release of Chef.
    .EXAMPLE
    iex (irm '<%= base_url %>/install.ps1'); Get-ProjectMetadata -project chefdk -channel stable -version 0.8.0

    Gets the download url and SHA256 checksum for ChefDK 0.8.0.
  #>
  [cmdletbinding()]
  param (
    # Base url to retrieve metadata from.
    [uri]$base_server_uri = '<%= base_url %>',
    [string]
    # Project to install
    [string]
    $project = 'chef',
    # Version of the application to install
    # This parameter is optional, if not supplied it will provide the latest version,
    # and if an iteration number is not specified, it will grab the latest available iteration.
    # Partial version numbers are also acceptable (using v=11
    # will grab the latest 11.x client which matches the other flags).
    [string]
    $version,
    # Release channel to install from
    [validateset('current', 'stable', 'unstable')]
    [string]
    $channel = 'stable',
    # The following legacy switches are just aliases for the current channel
    [switch]
    $prerelease,
    [switch]
    $nightlies,
    [validateset('auto', 'i386', 'x86_64')]
    [string]
    $architecture = 'auto'
  )

  # The following legacy switches are just aliases for the current channel
  if (($prerelease -eq $true)) { $channel = 'current'}
  if (($nightlies -eq $true)) { $channel = 'current'}

  # PowerShell is only on Windows ATM
  $platform = 'windows'
  Write-Verbose "Platform: $platform"

  $platform_version = Get-PlatformVersion
  Write-Verbose "Platform Version: $platform_version"

  if ($architecture -eq 'auto') {
    $architecture = Get-PlatformArchitecture
  }

  Write-Verbose "Architecture: $architecture"
  Write-Verbose "Project: $project"

  $metadata_base_url = "/$($channel)/$($project)/metadata"
  $metadata_array = ("?v=$($version)",
    "p=$platform",
    "pv=$platform_version",
    "m=$architecture")
  $metadata_base_url += [string]::join('&', $metadata_array)
  $metadata_url = new-uri $base_server_uri $metadata_base_url

  Write-Verbose "Downloading $project details from $metadata_url"
  $package_metadata = (Get-WebContent $metadata_url).trim() -split '\n' |
    foreach { $hash = @{} } {$key, $value = $_ -split '\s+'; $hash.Add($key, $value)} {$hash}

  Write-Verbose "Project details: "
  foreach ($key in $package_metadata.keys) {
    Write-Verbose "`t$key = $($package_metadata[$key])"
  }
  $package_metadata
}
