functions/private/Start-Log.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function Start-Log{
    [OutputType([string])]
    [CmdletBinding()]
    param(
    [Parameter()]
    [ValidateNotNullOrEmpty()]
    [string] $LogName = "FlexdeskBlueprint_$(([guid]::newguid().guid)).log"
    )
    # recreates the log file and sets the script parameter for use in the write-log function

    $_Log = "$env:APPDATA\FlexdeskBlueprint\logs\$($LogName)"
# if(Test-Path -Path $script:Log){
# $null=remove-item -path $script:Log -force
        #}
    $LogDirectory = Split-Path $_Log
    if((Test-Path -Path $LogDirectory) -eq $false){
        $null = new-item -Path $LogDirectory -ItemType Directory -Force
    }
    $null= new-item -type file -path $_Log
    return $_Log
}