commands

^

Get-DbaRandomizedValue

Author Sander Stad (@sqlstad, sqlstad.nl)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaRandomizedValue on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaRandomizedValue.

Synopsis

This function will generate a random value for a specific data type or bogus type and subtype

Description

Generates a random value based on the assigned sql data type or bogus type with sub type.
It supports a wide range of sql data types and an entire dictionary of various random values.

Syntax

Get-DbaRandomizedValue
    [[-DataType] <String>]
    [[-RandomizerType] <String>]
    [[-RandomizerSubType] <String>]
    [[-Min] <Object>]
    [[-Max] <Object>]
    [[-Precision] <Int32>]
    [[-CharacterString] <String>]
    [[-Format] <String>]
    [[-Symbol] <String>]
    [[-Separator] <String>]
    [[-Value] <String>]
    [[-Locale] <String>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaRandomizedValue -DataType bit

Will return either a 1 or 0

Example: 2
PS C:\> Get-DbaRandomizedValue -DataType int

Will generate a number between -2147483648 and 2147483647

Example: 3
PS C:\> Get-DbaRandomizedValue -RandomizerSubType Zipcode

Generates a random zipcode

Example: 4
PS C:\> Get-DbaRandomizedValue -RandomizerSubType Zipcode -Format "#### ##"

Generates a random zipcode like "1234 56"

Example: 5
PS C:\> Get-DbaRandomizedValue -RandomizerSubType PhoneNumber -Format "(###) #######"

Generates a random phonenumber like "(123) 4567890"

Optional Parameters

-DataType

The target SQL Server instance or instances.
Supported data types are bigint, bit, bool, char, date, datetime, datetime2, decimal, int, float, guid, money, numeric, nchar, ntext, nvarchar, real, smalldatetime, smallint, text, time, tinyint,
uniqueidentifier, userdefineddatatype, varchar

Alias
Required False
Pipeline false
Default Value
-RandomizerType

Bogus type to use.
Supported types are Address, Commerce, Company, Database, Date, Finance, Hacker, Hashids, Image, Internet, Lorem, Name, Person, Phone, Random, Rant, System

Alias
Required False
Pipeline false
Default Value
-RandomizerSubType

Subtype to use.

Alias
Required False
Pipeline false
Default Value
-Min

Minimum value used to generate certain lengths of values. Default is 1

Alias
Required False
Pipeline false
Default Value
-Max

Maximum value used to generate certain lengths of values. Default is 255

Alias
Required False
Pipeline false
Default Value
-Precision

Precision used for numeric sql data types like decimal, numeric, real and float

Alias
Required False
Pipeline false
Default Value 2
-CharacterString

The characters to use in string data. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' by default

Alias
Required False
Pipeline false
Default Value abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
-Format

Use specilized formatting with certain randomizer types like phone number.

Alias
Required False
Pipeline false
Default Value
-Symbol

Use a symbol in front of the value i.e. $100,12

Alias
Required False
Pipeline false
Default Value
-Separator

Some masking types support separators

Alias
Required False
Pipeline false
Default Value
-Value

This is the value that needs to be used for several possible transformations.
One example is the subtype "Shuffling" where the value will be shuffled.

Alias
Required False
Pipeline false
Default Value
-Locale

Set the local to enable certain settings in the masking. The default is 'en'

Alias
Required False
Pipeline false
Default Value en
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False