Creating PowerShell Scripts

PHOTO EMBED

Wed Dec 28 2022 01:34:00 GMT+0000 (Coordinated Universal Time)

Saved by @savabeh191

<#
  .SYNOPSIS
  Create test files in given directory

  .DESCRIPTION
  The script generates an x amount of text file based test file in the given folder. The files don't
  contain any content.

  .EXAMPLE
  CreateTestFiles.ps1 -path c:\temp -amount 50

  Create 50 files in c:\temp
  
  .NOTES
  Version:        1.0
  Author:         R. Mens - LazyAdmin.nl
  Creation Date:  04 oct 2022
  Modified Date:  
  Purpose/Change: Init
  Link:           https://lazyadmin.nl/powershell/powershell-scripting
#>

param(
  [Parameter(
  Mandatory=$true,
  HelpMessage="Enter path were test files should be created")]
  [string]$path,
  
  [Parameter(
  HelpMessage="How many files should be created"
  )]
  [int]$amount=10
)

# Create files
1..10 | ForEach-Object {
    $newFile = "$path\test_file_$_.txt";
    New-Item $newFile
}
content_copyCOPY

https://lazyadmin.nl/powershell/powershell-script/