Invoke-IDSqlcmd

Invoke-IDSqlcmd

SYNOPSIS

Query the database tables

SYNTAX

Invoke-IDSqlcmd [-Script] <String> [[-Limit] <Int32>] [[-PageNumber] <Int32>] [[-PageSize] <Int32>]
 [[-Caching] <Int32>] [[-Direction] <Boolean>] [[-SortBy] <String>] [<CommonParameters>]

DESCRIPTION

The SQL query interface allows you to read database tables for the Identity Solution. It does not allow you to modify or create data in these tables.

This function requires a script with the SQL code to execute as a query and optional parameters to control the output.

The underlying Redrock query API only honors -Limit when it’s paired with -PageNumber/-PageSize; without them, the full result set is returned regardless of -Limit. If -Limit is supplied without an explicit -PageSize and/or -PageNumber, this function defaults -PageSize to the -Limit value and -PageNumber to 1, so -Limit alone behaves as expected. Explicitly supplied -PageSize/-PageNumber values are never overridden.

EXAMPLES

Example 1

PS C:\> Invoke-IDSqlcmd -Script 'Select ID, Username from User ORDER BY Username COLLATE NOCASE'

Invoke query on the User table, returning the ID and name for each user who has accessed the cloud service

Example 2

PS C:\> Invoke-IDSqlcmd -Script 'Select ID, Username from User ORDER BY Username COLLATE NOCASE' -Limit 10

Invoke query on the User table, returning at most the first 10 results. -PageSize and -PageNumber are defaulted automatically from -Limit.

PARAMETERS

-Caching

How the results should be cached.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Direction

Whether the results are sorted in ascending or descending order.

  • True: The results are sorted in ascending order.
  • False: The results are sorted in descending order.
Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Limit

The maximum number of results to return for the specified page.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-PageNumber

The specific page number of results to be returned.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-PageSize

The number of entities to return per page.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Script

The SQL code to execute

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-SortBy

An optional, comma-separated list of column names to sort by.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Default value: None
Accept pipeline input: True (ByPropertyName)
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

System.String

System.Int32

System.Boolean

OUTPUTS

System.Object

NOTES