Skip to content

New-RandomFileName

SYNOPSIS

Create a random file name.

SYNTAX

none (Default)

New-RandomFileName [-Extension <String>] [<CommonParameters>]

temp

New-RandomFileName [-Extension <String>] [-UseTempFolder] [<CommonParameters>]

home

New-RandomFileName [-Extension <String>] [-UseHomeFolder] [<CommonParameters>]

DESCRIPTION

Create a new random file name. The default is a completely random name including the extension. But you can also create a filename that includes either the TEMP folder or the user's home folder. In the case of a Windows system, the home folder will be the documents folder.

This command does not create the file, it only generates a name for you to use.

EXAMPLES

EXAMPLE 1

PS C:\> New-RandomFileName
fykxecvh.ipw

EXAMPLE 2

PS C:\> New-RandomFileName -extension dat
emevgq3r.dat

Specify a file extension.

EXAMPLE 3

PS C:\> New-RandomFileName -extension log -UseHomeFolder
C:\Users\Jeff\Documents\kbyw4fda.log

Create a random file name using the user's home folder. In Windows, this will be the Documents folder.

EXAMPLE 4

PS /mnt/c/scripts> new-randomfilename -home -Extension tmp
/home/jhicks/oces0epq.tmp

Create a random file name using the user's home folder on a Linux installation.

PARAMETERS

-Extension

Use a specific extension. Do not include the period.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UseHomeFolder

Include the user's HOME folder.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: home
Aliases: home

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-UseTempFolder

Include the TEMP folder.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: temp
Aliases: temp

Required: False
Position: Named
Default value: False
Accept pipeline input: False
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

None

OUTPUTS

System.String

NOTES

Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/

New-CustomFileName

Back to top