Skip to content

Instantly share code, notes, and snippets.

@dmtrek14
Created July 15, 2022 17:07
Show Gist options
  • Save dmtrek14/9992f6f91cf5910867a05465c9ab279f to your computer and use it in GitHub Desktop.
Save dmtrek14/9992f6f91cf5910867a05465c9ab279f to your computer and use it in GitHub Desktop.
Powershell script to make a copy of just the structure of a folder
param
(
[parameter(Mandatory = $true)]
[String] $ExistingFolderName,
[parameter(Mandatory = $true)]
[String] $CopiedFolderName
)
function Create-FolderStructureCopy {
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[string] $ExistingFolderName ,
[parameter(Mandatory = $true)]
[String] $CopiedFolderName
)
process {
#module for notifications
Install-Module -Name BurntToast -SkipPublisherCheck -Force
$copiedFolderDestination = "{path to copied folder}"
## copied folder destination
Set-Location $copiedFolderDestination
if (!(Test-Path $CopiedFolderName)) {
Write-Host "Starting copy of exisiting folder structure ..."
robocopy $ExistingFolderName $CopiedFolderName /e /xf *
New-BurntToastNotification -Text "$CopiedFolderName Folder Structure Created", 'Empty folder structure has been created.'
}
else {
Write-Host "Folder for $CopiedFolderName already exists"
}
}
}
Create-FolderStructureCopy -ExistingFolderName $ExistingFolderName -CopiedFolderName $CopiedFolderName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment