mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-21 23:43:25 +01:00
Improved new-symlink.ps1
This commit is contained in:
parent
49b8331361
commit
3d30f79176
@ -1,14 +1,15 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates a new symbolic link file
|
Creates a new symlink
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script creates a new symbolic link file.
|
This PowerShell script creates a new symbolic link file, linking to a target.
|
||||||
.PARAMETER symlink
|
.PARAMETER symlink
|
||||||
Specifies the new symlink filename
|
Specifies the path to the new symlink file
|
||||||
.PARAMETER target
|
.PARAMETER target
|
||||||
Specifies the path to target
|
Specifies the path to the target
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./new-symlink.ps1 C:\Temp\HDD C:\
|
PS> ./new-symlink.ps1 C:\User\Markus\Windows C:\Windows
|
||||||
|
✅ New symlink file 'C:\User\Markus\Windows' created, linking to: C:\Windows
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -18,12 +19,12 @@
|
|||||||
param([string]$symlink = "", [string]$target = "")
|
param([string]$symlink = "", [string]$target = "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($symlink -eq "" ) { $symlink = read-host "Enter new symlink filename" }
|
if ($symlink -eq "" ) { $symlink = Read-Host "Enter new symlink filename" }
|
||||||
if ($target -eq "" ) { $target = read-host "Enter path to target" }
|
if ($target -eq "" ) { $target = Read-Host "Enter path to target" }
|
||||||
|
|
||||||
new-item -path "$symlink" -itemType SymbolicLink -Value "$target"
|
New-Item -path "$symlink" -itemType SymbolicLink -value "$target"
|
||||||
|
|
||||||
"✅ created new symlink $symlink ⭢ $target"
|
"✅ New symlink file '$symlink' created, linking to: $target"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user