Thank you so much.
I simplified the code when I posted it, replacing the command line parameter:
param (
[string]$arg_fullN_01='default'
)
with the statement: $path = “E:\Apps\UtilPS\deleete.pdf (Shortcut).lnk”
I’m telling you this because I’m too ignorant to understand how to use the parameters for your function:
param (
[Parameter()]
[ValidateScript({Test-Path $_})]
[System.IO.FileInfo]$Path
)
In my param statement above, there is only one bracketed thing, [string]
.
Your param statement has three bracketed things:
I don’t understand the role of [Parameter()]
or the role of [ValidateScript({Test-Path $_})]
.
I presume that [System.IO.FileInfo]$Path
is a way of checking that a valid path was used as an argument. Am I right?
Could you direct me to a URL where I could learn how to feed the right strings to your function?
To show you what I mean by that question, the original script, as improved according to the helpful input from @krzydoug, runs just fine under Windows PS, when I run the following Terminal command:
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" E:\Apps\UtilPS\powershell_make_shortcut_using_powershell_SAVE_aaa.ps1" "E:\Apps\UtilPS\deleete.pdf (Shortcut).lnk"
But when I run the script under PS7, using the following command line, it opens “This PC”
"C:\Program Files\PowerShell\7\pwsh.exe" "E:\Apps\UtilPS\powershell_make_shortcut_using_powershell_SAVE_aaa.ps1" "E:\Apps\UtilPS\deleete.pdf (Shortcut).lnk"
In the terminal command above, which runs the script under PS7, the path, I feed the path-string "E:\Apps\UtilPS\deleete.pdf (Shortcut).lnk"
to the param statement:
param (
[string]$arg_fullN_01='default'
)
Assuming I remove from the script the statement:
$path = "E:\Apps\UtilPS\deleete.pdf (Shortcut).lnk"
,
how should I modify the script AND the command line, to use your function?
Any suggestions about where I could learn what I am missing would be much appreciated.
Thank you again. I really do appreciate your generosity and @krzydoug’s generosity in helping me.
Marc