Repository navigation
Add CurrencyMember
Adds a new member to an object that is a currency conversion of one of its existing properties.
Add-CurrencyMember -InputObject <PSObject> [-Property] <String> [[-MemberName] <String>] [-From <String>]
[-To <String>] [-APIKey <String>] [-Date <DateTime>] [-PassThru] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Converts the value of an existing property on a PowerShell object to another currency, and adds the result as a new property on that same object via Add-Member. Uses Convert-Currency or Convert-CryptoCurrency to perform the conversion, depending on whether -From/-To are crypto currencies. As with Add-Member, the updated object is only returned to the pipeline if -PassThru is specified.
[pscustomobject]@{ Product = 'Widget'; Price = 100 } | Add-CurrencyMember -Property Price -From USD -To GBP -PassThru
Adds a PriceGBP property to the object, with the Price property converted from USD to GBP, and returns the updated object.
$Orders | Add-CurrencyMember -Property Total -MemberName TotalEUR -From USD -To EUR
Adds a TotalEUR property to each object in $Orders, with the Total property converted from USD to EUR.
Set-CurrencyDefault -From USD -To GBP
[pscustomobject]@{ Price = 100 } | Add-CurrencyMember -Property Price -PassThru
Uses the saved default -From/-To currencies to add a PriceGBP property, and returns the updated object.
[pscustomobject]@{ Price = 1 } | Add-CurrencyMember -Property Price -From BTC -To GBP -PassThru
Adds a PriceGBP property, with the Price property converted from BTC to GBP via Convert-CryptoCurrency, and returns the updated object.
[pscustomobject]@{ Price = 100 } | Add-CurrencyMember -Property Price -From USD -To GBP -Date '2024-01-15' -ApiKey yourapikeystringhere -PassThru
Adds a PriceGBP property, with the Price property converted from USD to GBP using the exchange rate as it was on 15th January 2024, and returns the updated object.
The object to add the new member to. Can be provided via the pipeline.
Type: PSObject
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseThe name of the existing property on InputObject whose value should be converted.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name of the new property to add to InputObject, containing the converted value. Defaults to "<Property><To>", e.g. a -Property of 'Price' and -To of 'GBP' would add a 'PriceGBP' property.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe currency to convert from. Defaults to the value saved with Set-CurrencyDefault -From, if any.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-CurrencyDefaultValue -Name 'From')
Accept pipeline input: False
Accept wildcard characters: FalseThe currency to convert to. Defaults to the value saved with Set-CurrencyDefault -To, if any.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-CurrencyDefaultValue -Name 'To')
Accept pipeline input: False
Accept wildcard characters: FalseOptional: To use the v6 API, provide your API key, as provided by https://www.exchangerate-api.com/ Defaults to the value saved with Set-CurrencyDefault -APIKey, if any. Not used when converting to/from a crypto currency.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-CurrencyDefaultValue -Name 'APIKey')
Accept pipeline input: False
Accept wildcard characters: FalseOptional: Converts using the historical exchange rates for the specified date, instead of the latest rates. This requires an -APIKey, as historical data is only available via the registered v6 API. Not supported when converting to/from a crypto currency.
Type: DateTime
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseReturns the updated object to the pipeline. By default, this cmdlet does not generate any output.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
https://github.com/markwragg/PowerShell-CurrencyConverter/wiki/Add-CurrencyMember