Zum Inhalt springen

PowerShell Snippet 04/ 2017

Wer auf die Schnelle ein paar tausend Text-Dateien mit Inhalt benötigt, der ist zügig mit folgendem Snippet fertig.
Die hier erzeugte Dateien haben eine Größe von ca. 3 KB.

$collection=1..100 | ForEach-Object {Get-Random}
$x=0
$pfad= 'c:\temp\_test'
do
{
New-Item -Path $pfad -Name "$x.txt" -ItemType File -Force
$collection | out-file -FilePath "$pfad\$x.txt" -Append
$x=$x+1
}
until ($x -gt 10000)