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

Function that will accept source agreement #2020

Merged
merged 1 commit into from
Mar 16, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,32 @@ Function Add-WinGetSource
This example adds a new source to the Windows Package Manager named "custom"

.EXAMPLE
Add-WinGetSource -Name "custom" -Argument "https://contoso.com/" -Type "Microsoft.Rest" -Header "string"
Add-WinGetSource -Name "custom" -Argument "https://contoso.com/" -Type "Microsoft.Rest" -Header "string" -AcceptSourceAgreement:$true

This example adds a new source to the Windows Package Manager named "custom" and passes the value "string" in the Windows-Package-Manager HTTP header to the source.
#>

PARAM(
[Parameter(Mandatory=$true)] [string] $Name,
[Parameter(Mandatory=$true)] [string] $Argument,
[Parameter(Mandatory=$true)] [ValidateSet("Microsoft.Rest", "Microsoft.PreIndexed.Package")] [string] $Type,
[Parameter(Mandatory=$true)] [ValidateSet("Microsoft.Rest", "Microsoft.PreIndexed.Package")] [string]$Type,
[Parameter()] [ValidateLength(1, 1024)] $Header,
[Parameter()] [switch] $AcceptSourceAgreement
[Parameter()] [bool] $AcceptSourceAgreement
)
BEGIN
{
[string[]] $WinGetArgs = "Source", "Add"
$WinGetArgs += "--Name", $Name
$WinGetArgs += "--Arg", $Argument
$WinGetArgs += "--Type", $Type
if ($AcceptSourceAgreement) {$acceptOption = '--accept-source-agreements'}
[string] $WinGetArgs = "Source Add --Name {0} --Arg {1} --Type {2} {3}" -f $Name, $Argument, $Type, $acceptOption
}
PROCESS
{
& "WinGet" $WingetArgs
Start-Process -FilePath "winget.exe" -ArgumentList $WinGetArgs -Wait
}
END
{
return
#Don't do this unless you are in a class
#return
}
}

Export-ModuleMember -Function Add-WinGetSource
Export-ModuleMember -Function Add-WinGetSource