Public/Get-GW2GuildSearch.ps1

<#
.SYNOPSIS
Searches for a guild ID by name using the Guild Wars 2 API.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /guild/search endpoint.
Returns the guild ID for the provided guild name.
 
.PARAMETER Name
Required. The full name of the guild to search for.
Example: "ArenaNet"
 
.EXAMPLE
Get-GW2GuildSearch -Name "ArenaNet"
Returns the guild ID for "ArenaNet".
 
.NOTES
- Requires network access to api.guildwars2.com.
- This is a public endpoint and does not require an API key.
- The name parameter must be URL-encoded, which this script handles.
#>

function Get-GW2GuildSearch {
    param (
        [Parameter(Mandatory = $true)]
        [string]$Name
    )
    
    $encodedName = [System.Web.HttpUtility]::UrlEncode($Name)
    $url = "https://api.guildwars2.com/v2/guild/search?name=$encodedName"
    
    $response = Invoke-RestMethod -Uri $url -Method Get
    
    return $response
}