Function New-Symlink { <# .SYNOPSIS Create a new symlink. This function is to make my life as a SRE or developer a lot easier. .PARAMETER ActualFilePath [string] The place where the file is actually at .PARAMETER TargetFilePath [string] The place where the file should appear to be .PARAMETER TargetName [string] The name to use for the target. If not supplied, will match the filename or folder name of the ActualFilePath (Path) #> [CmdletBinding()] Param( [Alias("Path")] [Alias("Source")] [Parameter(Mandatory = $true)] [string]$ActualFilePath, [Alias("Destination")] [Alias("Target")] [Parameter(Mandatory = $true)] [string]$TargetFilePath, [Alias("Name")] [Parameter(Mandatory = $false)] [string]$TargetName ) $loglead = (Get-LogLeadName) $ActualFilePath = Resolve-Path $ActualFilePath if (!(Test-Path $ActualFilePath)) { Write-Warning "$logLead : The requested path to be linked doesn't actually exist on disk [$ActualFilePath]" return } $actualLeaf = (Split-Path $ActualFilePath -Leaf) $targetLeaf = (Split-Path $TargetFilePath -Leaf) $leafNamesMatch = $actualLeaf -eq $targetLeaf if ([string]::IsNullOrWhiteSpace($TargetName) -and !$leafNamesMatch) { $TargetName = $actualLeaf } Write-Host "$logLead : New-Item -ItemType SymbolicLink -Path $TargetFilePath -Value $ActualFilePath -Name $TargetName -Force" (New-Item -ItemType SymbolicLink -Path $TargetFilePath -Value $ActualFilePath -Name $TargetName -Force) | Out-Null }