I put the following function in my powershell profile
(path from echo $profile, mine is like D:\C_Drive\Hardlink\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1)
function test {
[cmdletbinding(SupportsShouldProcess)]
ls
}
Set-Alias ggg test
with [cmdletbinding(SupportsShouldProcess)] to prompt confirmation, but I get the following error when running ggg
At D:\C_Drive\Hardlink\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:2 char:5
+ [cmdletbinding(SupportsShouldProcess)]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute 'cmdletbinding'.
At D:\C_Drive\Hardlink\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:3 char:5
+ ls
+ ~~
Unexpected token 'ls' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedAttribute
What is the right way to confirm before executing command in function?