Maybe bug in v4 New-ADTShortcut Path parameter validation script

I think $Path in this part of the validation script:

if (![System.IO.Path]::GetExtension($Path).ToLower().Equals(‘.lnk’) -and ![System.IO.Path]::GetExtension($Path).ToLower().Equals(‘.url’))

should be $_

if (![System.IO.Path]::GetExtension($_).ToLower().Equals(‘.lnk’) -and ![System.IO.Path]::GetExtension($_).ToLower().Equals(‘.url’))

I was getting an error saying that $Path was not defined or something (forgot to copy the error) even when trying the New-ADTShortcut example provided in the docs. I changed $Path to $_, imported the module again and the New-ADTShortcut example worked as expected.

In case it matters, I’m working in a Windows 11 sandbox.

I’ve not done much with parameter validation so let me know if I’m not interpreting this correctly. Or if I should be logging this somewhere else.

Apologies. Just found the closed bug report here from last week:

Fix will be in the next point release.

3 Likes

PSAppDeployToolkit is on GitHub.
Any issues you find with the Toolkit should be reported here: PSAppDeployToolkit/PSAppDeployToolkit: Project Homepage & Forums
and any issues with the new PSAppDeployToolkit.Tools should be reported here: PSAppDeployToolkit/PSAppDeployToolkit.Tools: Companion module for PSAppDeployToolkit

2 Likes

Just to fully close the loop on this, this bug also existed in the other shortcut functions. They’ve been amended in our develop branch and will be in the next point release: - Apply fix from "- Fix bad setup in `New-ADTShortcut`'s `-Path` Vali… · PSAppDeployToolkit/PSAppDeployToolkit@2e7766b · GitHub