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.
This function will generate a random value for a specific data type or bogus type and subtype
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.
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>]
PS C:\> Get-DbaRandomizedValue -DataType bit
Will return either a 1 or 0
PS C:\> Get-DbaRandomizedValue -DataType int
Will generate a number between -2147483648 and 2147483647
PS C:\> Get-DbaRandomizedValue -RandomizerSubType Zipcode
Generates a random zipcode
PS C:\> Get-DbaRandomizedValue -RandomizerSubType Zipcode -Format "#### ##"
Generates a random zipcode like "1234 56"
PS C:\> Get-DbaRandomizedValue -RandomizerSubType PhoneNumber -Format "(###) #######"
Generates a random phonenumber like "(123) 4567890"
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 |
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 |
Subtype to use.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Minimum value used to generate certain lengths of values. Default is 1
Alias | |
Required | False |
Pipeline | false |
Default Value |
Maximum value used to generate certain lengths of values. Default is 255
Alias | |
Required | False |
Pipeline | false |
Default Value |
Precision used for numeric sql data types like decimal, numeric, real and float
Alias | |
Required | False |
Pipeline | false |
Default Value | 2 |
The characters to use in string data. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' by default
Alias | |
Required | False |
Pipeline | false |
Default Value | abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 |
Use specilized formatting with certain randomizer types like phone number.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Use a symbol in front of the value i.e. $100,12
Alias | |
Required | False |
Pipeline | false |
Default Value |
Some masking types support separators
Alias | |
Required | False |
Pipeline | false |
Default 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 |
Set the local to enable certain settings in the masking. The default is 'en'
Alias | |
Required | False |
Pipeline | false |
Default Value | en |
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 |