DataStructure.psm1

<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.150
     Generated on: 28/06/2018 9:48 PM
     Generated by: rhysm
    --------------------------------------------------------------------------------
    .DESCRIPTION
        Script generated by PowerShell Studio 2018
#>



<#
    ===========================================================================
     Created by: Rhys M
     Contact: RhysM.PS@gmail.com
     PS Gallery: https://www.powershellgallery.com/profiles/RhysM/
      
     Filename: DataStructure.psm1
    -------------------------------------------------------------------------
     Module Name: DataStructure
    ===========================================================================
#>


<#
    .EXTERNALHELP DataStructure.psm1-Help.xml
#>

function DataStructure-Blank
{
    Param (
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Folder path you want to utilise")]
        $Path,
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Base name of sub folders implemented")]
        $SubFolderName,
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Number of items of each type you want created")]
        $FileCount
    )

    foreach($Directory in $Path)
    {
      
        $NUM = 1..$FileCount
        $FileType = @(

        "TXT","RTF","DOCX","DOC",
        "XLSX","ZIP","RAR","PDF",
        "HTML","LOG","CSV","XML",
        "DAT","BIN","JPG","BMP",
        "GIF","ICO","CFG","DMP",
        "TMP","INI","SYS","MP3",
        "WAV","AAC","WMA","FLAC",
        "CS","MSG","TEX","WPD",
        "WPS","GED","KEY","KEYCHAIN",
        "SDF","BAT","TAR","VCF",
        "IAF","IFF","M3U","M4A",
        "MID","RM","SRT","SWF",
        "VOB","3DM","3DS","MAX",
        "OBJ","TIF","TIFF","PSPIMAGE",
        "PSD","YUV","PART","PCT",
        "INDD","XLR","XLS","CPP",
        "DB","DBF","MDB","PDB",
        "SQL","CRDOWNLOAD","CGI","COM",
        "EXE","GADGET","JAR","WSF",
        "CAB","CPL","CUR","DLL",
        "ICS","DRV","ICNS","LNK",
        "TORRENT","VCD","PRF","ISO"

        )


        # Top Level Folder Existance Validation

        $FolderExists = Test-Path $Path 
            If ($FolderExists -eq $True)
             {
                write-host ""
                Write-Host "$Path DIR Allready Exists"
             }
                Else 
             {
                New-Item $Path -type directory
                write-host ""
                Write-Host "$Path - Directory Created"
                sleep(2)
             }


        # Content Creation Begin

        $Time_Start = Get-Date -Format G
        write-host "Started: $Time_Start" -ForegroundColor Cyan

        Measure-Command {

        foreach ($Number in $Num){
            $FolderName = "$SubFolderName" + "$Number"
            new-item -Name $FolderName -ItemType directory -Path $Path

                Foreach ($File in $FileType){

                    foreach ($Number in $Num){
                    $Filename = "Blank$File" + "File_$Number.$File"
                    write-host "Creating: $Filename" -ForegroundColor Green
                    write-host "Current Processing Directory: $Path\$FolderName" -ForegroundColor Cyan
                    New-Item "$Path\$FolderName\$Filename" -ItemType file

                    } 
              }
        }

        }

        $Time_End = Get-Date -Format G
        write-output "Completed: $Time_End" 

        $DIRCONTENT_Counter = Get-ChildItem $Path -Recurse
        $CreationCount = $DIRCONTENT_Counter.Count

        ""
        ""
        write-host "Total Content Created: $CreationCount Items." -ForegroundColor Cyan
        ""
        ""
        ""
        Write-Host "Creation Counter Data:" -ForegroundColor Cyan
        ""
        write-host "Start Time: $Time_Start"
        write-host "End Time: $Time_End"        


    }






}

<#
    .EXTERNALHELP DataStructure.psm1-Help.xml
#>

function DataStructure-Size
{
    Param (
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Folder path you want to utilise")]
        $Path,
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Base name of sub folders implemented")]
        $SubFolderName,
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Number of items of each type you want created")]
        $FileCount,
        [Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $true, HelpMessage = "Size of each file you are having created")]
        $FileSizeRequired

    )

    foreach($Directory in $Path)
    {
      
        $NUM = 1..$FileCount
        $FileType = @(

        "TXT","RTF","DOCX","DOC",
        "XLSX","ZIP","RAR","PDF",
        "HTML","LOG","CSV","XML",
        "DAT","BIN","JPG","BMP",
        "GIF","ICO","CFG","DMP",
        "TMP","INI","SYS","MP3",
        "WAV","AAC","WMA","FLAC",
        "CS","MSG","TEX","WPD",
        "WPS","GED","KEY","KEYCHAIN",
        "SDF","BAT","TAR","VCF",
        "IAF","IFF","M3U","M4A",
        "MID","RM","SRT","SWF",
        "VOB","3DM","3DS","MAX",
        "OBJ","TIF","TIFF","PSPIMAGE",
        "PSD","YUV","PART","PCT",
        "INDD","XLR","XLS","CPP",
        "DB","DBF","MDB","PDB",
        "SQL","CRDOWNLOAD","CGI","COM",
        "EXE","GADGET","JAR","WSF",
        "CAB","CPL","CUR","DLL",
        "ICS","DRV","ICNS","LNK",
        "TORRENT","VCD","PRF","ISO"

        )


        # Top Level Folder Existance Validation

        $FolderExists = Test-Path $Path 
            If ($FolderExists -eq $True)
             {
                write-host ""
                Write-Host "$Path DIR Allready Exists"
             }
                Else 
             {
                New-Item $Path -type directory
                write-host ""
                Write-Host "$Path - Directory Created"
                sleep(2)
             }


        # Content Creation Begin

        $Time_Start = Get-Date -Format G
        write-host "Started: $Time_Start" -ForegroundColor Cyan

        Measure-Command {

        foreach ($Number in $Num){
            $FolderName = "$SubFolderName" + "$Number"
            new-item -Name $FolderName -ItemType directory -Path $Path

                Foreach ($File in $FileType){

                    foreach ($Number in $Num){
                    $Filename = "BlankDataSize$File" + "File_$Number.$File"
                    write-host "Creating: $Filename" -ForegroundColor Green
                    write-Host "File Size: $FileSizeRequired" -ForegroundColor Magenta
                    write-host "Current Processing Directory: $Path\$FolderName" -ForegroundColor Cyan
                    $fileTBC = new-object System.IO.FileStream "$Path\$FolderName\$Filename", Create, ReadWrite
                    $fileTBC.SetLength($FileSizeRequired)
                    $fileTBC.Close()
                    
                    } 
              }
        }

        }

        $Time_End = Get-Date -Format G
        write-output "Completed: $Time_End" 

        $DIRCONTENT_Counter = Get-ChildItem $Path -Recurse
        $CreationCount = $DIRCONTENT_Counter.Count

        ""
        ""
        write-host "Total Content Created: $CreationCount Items." -ForegroundColor Cyan
        ""
        ""
        ""
        Write-Host "Creation Counter Data:" -ForegroundColor Cyan
        ""
        write-host "Start Time: $Time_Start"
        write-host "End Time: $Time_End"        


    }






}


Export-ModuleMember -Function DataStructure-Blank,
                    DataStructure-Size