I am attempting to write a semi-advanced function that will accept paths as parameters. However, I want one of the parameters to depend on an earlier parameter. Basically, it assumes the second item is a direct child item of the parent (a directory). But I’m not sure how to write the code. Here is what I have so far:
[cmdletbinding()] Param ( #Source file for parsing [string]$sourcedir = "E:\desired\source\directory", [string]$sourcefile = "$sourcedir\$sourcefile", [string]$archivedir = "$sourcedir\Archived", [string]$To = "email@example.com", [string]$From = "firstname.lastname@example.org" )
The $sourcefile parameter is what I’m struggling with. Since I’m feeding it the $sourcedir explicitly with the full path, I want the full path of the $sourcefile to be determined by only feeding the parameter the $sourcefile file name. Does that make sense?