Test-WithCulture
July 14, 2026 ยท View on GitHub
SYNOPSIS
Test your PowerShell code using a different culture.
SYNTAX
scriptblock (Default)
Test-WithCulture [-Culture] <CultureInfo> [-Scriptblock] <ScriptBlock> [-ArgumentList <Object[]>]
[<CommonParameters>]
file
Test-WithCulture [-Culture] <CultureInfo> -FilePath <ScriptBlock> [-ArgumentList <Object[]>]
[<CommonParameters>]
DESCRIPTION
When writing PowerShell commands, sometimes the culture you are running under becomes critical. For example, European countries use a different datetime format than North Americans which might present a problem with your script or command. Unless you have a separate computer running under the foreign culture, it is difficult to test. This command will allow you to test a scriptblock or even a file under a different culture, such as DE-DE for German.
Note that this command is not an absolute test. There may be commands that fail to produce the alternate culture results you expect.
EXAMPLES
Example 1
PS C:\> Test-WithCulture de-de -Scriptblock {(Get-Date).addDays(90)}
06.10.2026 15:01:50
Example2
PS C\> Test-WithCulture fr-fr -Scriptblock {
Get-winEvent -log system -max 500 |
Select-Object -Property TimeCreated,ID,OpCodeDisplayName,Message |
Sort-Object -property TimeCreated |
Group-Object {$_.TimeCreated.ToShortDateString()} -NoElement
}
Count Name
----- ----
22 06/07/2026
371 07/07/2026
107 08/07/2026
PARAMETERS
-ArgumentList
Specify an array of positional arguments to pass to the scriptblock for file.
Type: Object[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Culture
Enter a new culture like de-de
Type: CultureInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-FilePath
Enter the path to a PowerShell script file to execute using the specified culture.
Type: ScriptBlock
Parameter Sets: file
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Scriptblock
Enter a scriptblock to execute using the specified culture. Be aware that long or complex pipelined expressions might not give you the culture-specific results you expect.
Type: ScriptBlock
Parameter Sets: scriptblock
Aliases:
Required: True
Position: 1
Default value: None
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.Object
NOTES
Learn more about PowerShell: https://jdhitsolutions.com/yourls/newsletter