Skip to content

Symbolic Link Resource

Synopsis

Manages symbolic links on the local filesystem. Works on Windows, Linux, and macOS.

Type

OpenDsc.FileSystem/SymbolicLink

Capabilities

  • Get
  • Set
  • Delete

Properties

path

Path where the symbolic link should be created.

Type: string
Required: Yes
Access: Read/Write
Default value: None

target

Target path that the symbolic link points to.

Type: string
Required: Yes
Access: Read/Write
Default value: None

type

Link target type. Accepts File or Directory. Auto-detected if not specified.

Type: string
Required: No
Access: Read/Write
Default value: None

_exist

Whether the link should exist.

Type: bool
Required: No
Access: Read/Write
Default value: true

Examples

$resourceInput = @'
path: /usr/local/bin/myapp
target: /opt/myapp/bin/myapp
'@

dsc resource get -r OpenDsc.FileSystem/SymbolicLink --input $resourceInput
resource_input=$(cat <<'EOF'
path: /usr/local/bin/myapp
target: /opt/myapp/bin/myapp
EOF
)

dsc resource get -r OpenDsc.FileSystem/SymbolicLink --input "$resource_input"
$resourceInput = @'
path: /usr/local/bin/myapp
target: /opt/myapp/bin/myapp
'@

dsc resource set -r OpenDsc.FileSystem/SymbolicLink --input $resourceInput
resource_input=$(cat <<'EOF'
path: /usr/local/bin/myapp
target: /opt/myapp/bin/myapp
EOF
)

dsc resource set -r OpenDsc.FileSystem/SymbolicLink --input "$resource_input"
$resourceInput = @'
path: C:\Links\Logs
target: D:\AppLogs
type: Directory
'@

dsc resource set -r OpenDsc.FileSystem/SymbolicLink --input $resourceInput
resource_input=$(cat <<'EOF'
path: C:\Links\Logs
target: D:\AppLogs
type: Directory
EOF
)

dsc resource set -r OpenDsc.FileSystem/SymbolicLink --input "$resource_input"

Example 4 — Configuration document

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
  - name: Application symlink
    type: OpenDsc.FileSystem/SymbolicLink
    properties:
      path: /usr/local/bin/myapp
      target: /opt/myapp/bin/myapp

  - name: Log directory link
    type: OpenDsc.FileSystem/SymbolicLink
    properties:
      path: /var/log/myapp
      target: /mnt/storage/logs/myapp
      type: Directory

Exit codes

Code Description
0 Success
1 Error
2 Invalid JSON
3 Access denied
4 Invalid argument
5 IO error
6 Insufficient privileges