Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-User #109 #160

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions ConfluencePS/Public/Get-User.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function Get-User
{
[CmdletBinding(
SupportsPaging = $true,
DefaultParameterSetName = 'ByUsername'
)]
[OutputType([ConfluencePS.User])]
param (
[Parameter( Mandatory = $true )]
[URi]$ApiURi,

[Parameter( Mandatory = $true )]
[PSCredential]$Credential,

[Parameter( Mandatory = $true,
ParameterSetName = 'byUsername'
)]
[string]$Username,

[Parameter( Mandatory = $true,
ParameterSetName = 'byUserKey'
)]
[string]$UserKey
)

BEGIN
{
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"

$resourceApi = "$apiURi/user{0}"
}

PROCESS
{
Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = @{
Uri = ""
Method = 'Get'
OutputType = [ConfluencePS.User]
Credential = $Credential
}

# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
$iwParameters[$_] = $PSCmdlet.PagingParameters.$_
}
switch ($PsCmdlet.ParameterSetName)
{
'byUsername'
{
$iwParameters["Uri"] = $resourceApi -f "?username=$Username"
break
}
'byUserKey'
{
$iwParameters["Uri"] = $resourceApi -f "?key=$UserKey"
break
}
}
Invoke-Method @iwParameters
}

END
{
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
}
}
132 changes: 132 additions & 0 deletions docs/en-US/commands/Get-User.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
external help file: ConfluencePS-help.xml
online version: https://atlassianps.org/docs/ConfluencePS/commands/Get-User/
Module Name: ConfluencePS
locale: en-US
schema: 2.0.0
layout: documentation
permalink: /docs/ConfluencePS/commands/Get-User/
---
# Get-User

## SYNOPSIS

Retrieve a listing of Users in your Confluence instance.

## SYNTAX

### byUsername (Default)

```powershell
Get-ConfluenceUser -ApiURi <uri> -Credential <pscredential> -Username <string> [-IncludeTotalCount] [-Skip <uint64>] [-First <uint64>] [<CommonParameters>]
```

### byUserKey

```powershell
Get-ConfluenceUser -ApiURi <uri> -Credential <pscredential> -UserKey <string> [-IncludeTotalCount] [-Skip <uint64>] [-First <uint64>] [<CommonParameters>]
```

## DESCRIPTION

Return Confluence Users, filtered by Username, or Key.

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```powershell
Get-ConfluenceUser -Username 'myUser'
```

Returns a user by name.

### -------------------------- EXAMPLE 2 --------------------------

```powershell
Get-ConfluenceUser -UserKey 123456
```

Returns the user with ID 123456.

## PARAMETERS

### -ApiURi

The URi of the API interface.
Value can be set persistently with Set-ConfluenceInfo.

```yaml
Type: Uri
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Credential

Confluence's credentials for authentication.
Value can be set persistently with Set-ConfluenceInfo.

```yaml
Type: PSCredential
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -UserKey

Filter results by User key.

```yaml
Type: string
Parameter Sets: byUserKey
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Username

Filter results by Username (case-insensitive).

```yaml
Type: String
Parameter Sets: byUsername
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## INPUTS

None

## OUTPUTS

### ConfluencePS.User

## NOTES

## RELATED LINKS

[https://github.com/AtlassianPS/ConfluencePS](https://github.com/AtlassianPS/ConfluencePS)