Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Invoke-OdsApiRequest

Encapsulates setting the connection URI and credentials using the agent execution context information.

Invoke-OdsApiRequest -RequestPath <string>  [<CommonParameters>]

Description

The Invoke-OdsApiRequest cmdlet invokes the ODS API request and converts the JSON response into an array of PSCustomObject objects. If there was an error executing the request, it returns $null and logs the error to the Error output.

Examples

Example 1: retrieve Calendar Dates

$CalendarDates = Invoke-OdsApiRequest '/calendarDates'
foreach($CalendarDate in $CalendarDates) {
  Write-Output("Calendar date is " + $CalendarDate.date)
}

ConvertFrom-FixedWidth

Utility cmdlet for converting from a fixed-width row of text to an array of items.

ConvertFrom-FixedWidth -FixedWidthString <string> -FieldMap <ICollection>  [<CommonParameters>]

Description

Converts the fixed-width string into an array of items.

Examples

Example 1: converts a fixed-width string into an array of items using a simple mapping where each number in FieldMap represents the start position of the item in the fixed-width string.

ConvertFrom-FixedWidth -FixedWidthString "012 45 789" -FieldMap @(0, 4, 7)
---
012 
45 
789

Example 2: converts a fixed-width string into an array of items using a more complex mapping where each array of numbers in FieldMap represents the start position and the length of the item in the fixed-width string.

ConvertFrom-FixedWidth -FixedWidthString "012 45 789" -FieldMap @((0, 3), (4, 2), 7)
---
012
45
789

New-AgentCacheItem

Adds an object to the agent runtime cache so it is available during agent execution.

New-AgentCacheItem -Key <string> -Value <Object>  [<CommonParameters>]

Description

Sometimes it is useful from the performance perspective to share some data between preprocessors during the transform load process. The New-AgentCacheItem cmdlet puts an item into the agent cache. Once agents processes all files, the cache is disposed. If the item with the same key already exists, it gets overwritten.

Examples

Example 1: Add item to the agent cache.

New-AgentCacheItem -Key 'someKey' -Value 'Some data'

Get-AgentCacheItem

Gets an object from the agent runtime cache.

Get-AgentCacheItem -Key <string>  [<CommonParameters>]

Description

The Get-AgentCacheItem cmdlet retrieves the item from the agent runtime cache.

Examples

Example 1: Gets the item from the agent runtime cache.

Get-AgentCacheItem -Key 'someKey'

New-NamedArrayList

Creates an array list variable in PowerShell session to work around this bug in PowerShell.

New-NamedArrayList 
  [-Name] <string> 
  [-Collection <ICollection>] 
  [-Capacity <int>]  
  [<CommonParameters>]

Description

The New-NamedArrayList cmdlet creates a new instance of ArrayList and puts it with the specified name into the PowerShell session state. The motivation for the cmdlet was to work around the bug in PowerShell.

Examples

Example 1: Create a new named array list.


New-NamedArrayList TestArray

Example 2: Create a new named array list and initialize it with a collection.

New-NamedArrayList TestArray -Collection @(0, 4, 7)
Write-Output $A.Count
---
3

Example 3: Create a new named array list with predefined capacity. Note that the returned array list is a “copy” of the one created and maintained in the session state. So if you try Write-Output (New-NamedArrayList TestArray -Capacity 1000).Capacity it will return 4, not 1000.

New-NamedArrayList TestArray -Capacity 1000
New-NamedArrayList TestArray -Capacity 1000

Get-NamedArrayList

Gets the named array list from the PowerShell session.

Get-NamedArrayList [-Name] <string>  [<CommonParameters>]

Description

Returns named array list from the PowerShell session state.

Examples

Example 1: Create and then get named array list

$A = New-NamedArrayList TestArray -Collection @(0, 4, 7)
Write-Output (Get-NamedArrayList TestArray)
---
0
4
7

Add-CollectionItem

Adds the item to the named ArrayList. Creates a new named array list if it wasn’t previously created by the New-NamedArrayList cmdlet.

Add-CollectionItem -ArrayListName <string> -Item <Object>  [<CommonParameters>]

Description

The Add-CollectionItem cmdlet adds the item to the named array list.

Examples

Example 1: Add multiple items to the named array list.

$A  = New-NamedArrayList TestArray
$Item = @{
    Property1 = 'one'
    Property2 = 'two'
}
Add-CollectionItem -ArrayListName TestArray -Item '1'
Add-CollectionItem -ArrayListName TestArray -Item $Item
Write-Output  $A.Count
---
2

Remove-CollectionItem

Removes the item from the named ArrayList.

Remove-CollectionItem -ArrayListName <string> -Item <Object>  [<CommonParameters>]

Description

The Remove-CollectionItem cmdlet removes the item from the collection list.

Examples

Example 1: Remove the item from the named array list.

$A  = New-NamedArrayList TestArray
$Item = @{
    Property1 = 'one'
    Property2 = 'two'
}
Add-CollectionItem -ArrayListName TestArray -Item '1'
Add-CollectionItem -ArrayListName TestArray -Item $Item
Write-Output  $A.Count
Remove-CollectionItem -ArrayListName TestArray -Item $Item
Write-Output  $A.Count
---
2
1
  • No labels