SOLVED - see #3
Hi guys,
I am writing a PS script, and I want it to create a log file. The user selects a source folder during the script, and I want to get the date, call the log file date.txt and put it in the source folder.
I can get PS to concatenate my variables, but that results in a c:\sourcefolderdate.txt file.
I want a c:\sourcefolde\date.txt file instead.
I have tried adding a +="\" to my concatenation, but that does not work.
Any ideas?
Hi guys,
I am writing a PS script, and I want it to create a log file. The user selects a source folder during the script, and I want to get the date, call the log file date.txt and put it in the source folder.
I can get PS to concatenate my variables, but that results in a c:\sourcefolderdate.txt file.
I want a c:\sourcefolde\date.txt file instead.
I have tried adding a +="\" to my concatenation, but that does not work.
Any ideas?
Code:
#This function asks for the location of the build folder
function buildfolderloc {
$app = new-object -com Shell.Application
$script:buildfolder = $app.BrowseForFolder(0, "Select Folder", 0, "C")
$script:buildfolder = $buildfolder.Self.Path.ToString()
}
#This function creates a log file form a parsed date, and stores the name in a variable.
function createlogfile {
#Get date
$script:date=Get-Date
$script:date=$date.ToString("M-d-yyyy")
#Create log file based on date and build folder location
$logfilename = $buildfolder +="\" +=$date +=".txt"
New-Item $logfilename -type file
}
buildfolderloc
createlogfile
Last edited: