< Back

Get-DbaRandomizedValue

Mon Jan 13, 2020 11:31 am

NAME Get-DbaRandomizedValue



SYNOPSIS

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





SYNTAX

Get-DbaRandomizedValue [[-DataType] <String>] [[-RandomizerType] <String>] [[-RandomizerSubType] <String>] [[-Min]

<System.Object>] [[-Max] <System.Object>] [[-Precision] <Int>] [[-CharacterString] <String>] [[-Format] <String>]

[[-Symbol] <String>] [[-Value] <String>] [[-Locale] <String>] [-EnableException <Switch>] [<CommonParameters>]





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.





PARAMETERS

-CharacterString [<String>]

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

default



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DataType [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Format [<String>]

Use specilized formatting with certain randomizer types like phone number.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Locale [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Max [<System.Object>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Min [<System.Object>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Precision [<Int>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RandomizerSubType [<String>]

Subtype to use.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RandomizerType [<String>]

Bogus type to use.



Supported types are Address, Commerce, Company, Database, Date, Finance, Hacker, Hashids, Image, Internet,

Lorem, Name, Person, Phone, Random, Rant, System



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Symbol [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Value [<String>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: DataMasking, DataGeneration

Author: Sander Stad (@sqlstad, sqlstad.nl)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- 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"



RELATED LINKS

https://dbatools.io/Get-DbaRandomizedValue