SymbolicLinks pre V5

Welcome Forums General PowerShell Q&A SymbolicLinks pre V5

This topic contains 3 replies, has 3 voices, and was last updated by

3 years, 5 months ago.

  • Author
  • #32450

    Topics: 5
    Replies: 6
    Points: 66
    Rank: Member

    I got a script I'd like to deploy through group policy, but I wrote the script in PowerShell version 5 and it uses New-Item -ItemType SymbolicLink, unfortunately most computers in the domain are version 3. The SymbolicLink item type wasn't introduced until version 5 so my script isn't working. Is there a pre-version5 way of doing this?

    Thanks in advance!

  • #32451

    Topics: 9
    Replies: 2322
    Points: 0
    Rank: Member

    Not built into PowerShell, no. You could either find a .NET library that exposes this functionality (or write your own P/Invoke code, which is possible but not always easy), or you can just use something like junction.exe ( )

  • #32454

    Topics: 10
    Replies: 122
    Points: 2
    Rank: Member

    this is how I did it with mklink.exe. mklink is native to windows

    $date = @()
    $shadows = get-wmiobject win32_shadowcopy
    $num = 0
    Foreach($shadow in $shadows){
    $date += New-Object PSObject -Property ([ordered]@{Date = ("$num : " + [datetime]::ParseExact($shadow.InstallDate.Split(".")[0], "yyyyMMddHHmmss", $null))})
    $num ++
    $date | sort date -Descending
    $val = (Read-Host -Prompt "Please select restore date")
    $val2 = (Read-Host -Prompt "Please enter UserId")
    cmd.exe /c mklink /d "c:\ShadowCopy" ($shadows[$val].DeviceObject + "\users\$($val2)")
    Invoke-Item "C:\ShadowCopy"
  • #32455

    Topics: 5
    Replies: 6
    Points: 66
    Rank: Member

    Looks like that Junction only does junctions on the local computer and can't reach across the network. Maybe I'm looking at this wrong and instead of just making it work I should push out an update to v5 through group policy

The topic ‘SymbolicLinks pre V5’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort