Set GitHubAuthentication - X-Guardian/PowerShellForGitHub GitHub Wiki

Set-GitHubAuthentication

SYNOPSIS

Allows the user to configure the API token that should be used for authentication with the GitHub API.

SYNTAX

Set-GitHubAuthentication [[-Credential] <PSCredential>] [-SessionOnly] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

Allows the user to configure the API token that should be used for authentication with the GitHub API.

The token will be stored on the machine as a SecureString and will automatically be read on future PowerShell sessions with this module. If the user ever wishes to remove their authentication from the system, they simply need to call Clear-GitHubAuthentication.

The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub

EXAMPLES

EXAMPLE 1

Set-GitHubAuthentication

Prompts the user for their GitHub API Token and stores it in a file on the machine as a SecureString for use in future PowerShell sessions.

EXAMPLE 2

" | ConvertTo-SecureString -AsPlainText -Force)

$cred = New-Object System.Management.Automation.PSCredential "username is ignored", $secureString Set-GitHubAuthentication -Credential $cred $secureString = $null # clear this out now that it's no longer needed $cred = $null # clear this out now that it's no longer needed

Allows you to specify your access token as a plain-text string ("<Your Access Token>") which will be securely stored on the machine for use in all future PowerShell sessions.

EXAMPLE 3

Set-GitHubAuthentication -SessionOnly

Prompts the user for their GitHub API Token, but keeps it in memory only for the duration of this PowerShell session.

EXAMPLE 4

Set-GitHubAuthentication -Credential $cred -SessionOnly

Uses the API token stored in the password field of the provided credential object for authentication, but keeps it in memory only for the duration of this PowerShell session..

PARAMETERS

-Credential

If provided, instead of prompting the user for their API Token, it will be extracted from the password field of this credential object.

Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:

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

-SessionOnly

By default, this method will store the provided API Token as a SecureString in a local file so that it can be restored automatically in future PowerShell sessions. If this switch is provided, the file will not be created/updated and the authentication information will only remain in memory for the duration of this PowerShell session.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

⚠️ **GitHub.com Fallback** ⚠️