functions/private/Start-Log.ps1

function Start-Log{
    [CmdletBinding()]
    param(
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string] $LogName = "SMBDeployment-$(get-date -Format yyyyMMdd-HHmmssmsms)_$(([guid]::newguid().guid))"
    )
    # recreates the log file and sets the script parameter for use in the write-log function

    $script:Log = "$($script:Root)\Log\$($LogName)"
    if(Test-Path -Path $script:Log){
        $null=remove-item -path $script:Log -force
    }
    $LogDirectory = Split-Path $script:Log
    if((Test-Path -Path $LogDirectory) -eq $false){
        $null = new-item -Path $LogDirectory -ItemType Directory -Force
    }
    $null= new-item -type file -path $script:Log
}