SymbolicLinks pre V5

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!

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 ( )

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"

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