Get CosmosDbCollection - PlagueHO/CosmosDB GitHub Wiki
Return the collections in a Cosmos DB database.
Get-CosmosDbCollection -Context <Context> [-Key <SecureString>] [-KeyType <String>] [-Database <String>]
[-Id <String>] [-MaxItemCount <Int32>] [-ContinuationToken <String>] [-ResponseHeader <PSReference>]
[<CommonParameters>]
Get-CosmosDbCollection -Account <String> [-Key <SecureString>] [-KeyType <String>] [-Database <String>]
[-Id <String>] [-MaxItemCount <Int32>] [-ContinuationToken <String>] [-ResponseHeader <PSReference>]
[<CommonParameters>]
This cmdlet will return the collections in a Cosmos DB database. If the Id is specified then only the collection matching this Id will be returned, otherwise all collections will be returned.
A maxiumum of 100 collections will be returned if an Id is not specified. To retrieve more than 100 collections a continuation token will need to be used.
PS C:\> Get-CosmosDbCollection -Context $cosmosDbContext
Gets a list of collections in a database.
PS C:\> Get-CosmosDbCollection -Context $cosmosDbContext -Id 'MyNewCollection'
Get a the MyNewCollection collection from a database.
PS C:\> $ResponseHeader = $null
PS C:\> $collections = Get-CosmosDbCollection -Context $cosmosDbContext -MaxItemCount 5 -ResponseHeader ([ref] $ResponseHeader)
PS C:\> $continuationToken = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeader
Get the first 5 collections from the the database storing a continuation token that can be used to retrieve further blocks of collections.
PS C:\> $collections = Get-CosmosDbCollection -Context $cosmosDbContext -MaxItemCount 5 -ContinuationToken $continuationToken
Get the next 5 collections in the database using the continuation token found in the headers from the previous example.
PS C:\> $ResponseHeader = $null
PS C:\> $indexStringRange = New-CosmosDbCollectionIncludedPathIndex -Kind Range -DataType String -Precision -1
PS C:\> $indexNumberRange = New-CosmosDbCollectionIncludedPathIndex -Kind Range -DataType Number -Precision -1
PS C:\> $indexIncludedPath = New-CosmosDbCollectionIncludedPath -Path '/*' -Index $indexStringRange, $indexNumberRange
PS C:\> $newIndexingPolicy = New-CosmosDbCollectionIndexingPolicy -Automatic $true -IndexingMode Consistent -IncludedPath $indexIncludedPath
PS C:\> Set-CosmosDbCollection -Context $cosmosDbContext -Id 'MyExistingCollection' -IndexingPolicy $newIndexingPolicy
PS C:\> $collections = Get-CosmosDbCollection -Context $cosmosDbContext -Id 'MyExistingCollection' -ResponseHeader ([ref] $ResponseHeader)
PS C:\> $indexUpdateProgress = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeader -HeaderName 'x-ms-documentdb-collection-index-transformation-progress'
Update a collection with a new indexing policy and retrieve the index transformation progress.
The account name of the Cosmos DB to access.
Type: String
Parameter Sets: Account
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is an object containing the context information of the Cosmos DB database that will be deleted. It should be created by `New-CosmosDbContext`.
Type: Context
Parameter Sets: Context
Aliases: Connection
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A string token returned for queries and read-feed operations if there are more results to be read. Should not be set if Id is set.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the database to access in the Cosmos DB account.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is the id of the collection to get. If not specified all collections in the database will be returned.
Type: String
Parameter Sets: (All)
Aliases: Name
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The key to be used to access this Cosmos DB.
Type: SecureString
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The type of key that will be used to access ths Cosmos DB.
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: master, resource
Required: False
Position: Named
Default value: Master
Accept pipeline input: False
Accept wildcard characters: False
An integer indicating the maximum number of items to be returned per page. Should not be set if Id is set.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is a reference variable that will be used to return the hashtable that contains any headers returned by the request.
Type: PSReference
Parameter Sets: (All)
Aliases: ResultHeaders
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This 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).