-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate-File.ps1
More file actions
47 lines (40 loc) · 1.26 KB
/
Create-File.ps1
File metadata and controls
47 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
Create a file into the system.
.DESCRIPTION
Create a file into the system. However, If given path file does not exist into the system then create a new file at given $Path
.PARAMETER FolderPath*
Required. Directory path where to want to create a directory.
.PARAMETER FileName*
Required. FileName with extention.
.OUTPUTS
Generate a new file based on the $FileName at $FolderPath
.EXAMPLE
Create-File -FolderPath "FullPath/{DirectoryName}" -FileName "{FileName.extention}"
#>
function Create-File() {
[cmdletbinding()]
Param (
[Parameter(Mandatory = $true, Position = 0)]
[string] $FolderPath,
[Parameter(Mandatory = $true, Position = 1)]
[string] $FileName
)
Begin {
}
Process {
try {
Create-Directory -Path $FolderPath
$fullFilePath = $("$FolderPath\$FileName");
IF (!(Test-Path $fullFilePath)) {
New-Item -itemType File -Path $fullFilePath;
}
return $fullFilePath;
}
catch {
Write-Exception -ErrorObj $_ -Message "Throws an exception in 'Create-File', at: $FolderPath\$FileName" -Stop $true
}
}
End {
}
}