Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3720972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:23:48+00:00 2026-05-19T05:23:48+00:00

For example: function TestThis() { [MySpecialCustomAttribute] [CmdletBinding()] Param(…) Process{…} }

  • 0

For example:

function TestThis()
{
    [MySpecialCustomAttribute]
    [CmdletBinding()]
    Param(...)
    Process{...}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:23:49+00:00Added an answer on May 19, 2026 at 5:23 am

    Yes, of course you can!

    Any type derived from Attribute which allows UsageType.All (or UsageType.Class) can be used on the function itself (i.e. above Param)

    Any type derived from Attribute which allows UsageType.Property or UsageType.Field usage can be used on parameters themselves or variables.

    It’s not uncommon to just be lazy and use UsageType.All (e.g. the built in OutputType attribute does that).

    You can even write them in PowerShell classes now

    using namespace System.Management.Automation
    class ValidateFileExistsAttribute : ValidateArgumentsAttribute {
        [void] Validate([object]$arguments, [EngineIntrinsics]$engineIntrinsics) {
            if($null -eq $arguments) {
                throw [System.ArgumentNullException]::new()
            }
            if(-not (Test-Path -Path "$arguments" -Type Leaf)) {
                throw [System.IO.FileNotFoundException]::new("The specified path is not a file: '$arguments'")
            }        
        }
    }
    

    See more examples on Kevin Marquette‘s blog.

    There’s an older example here showing how to do it in PowerShell 4 and earlier using Add-Type, although it’s a little out of date now, because the particular example it shows has been integrated into PowerShell 6 and is no longer needed

    There are also videos

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple question related to one-line programming. First an example: function test(a)
For example: script.js: function functionFromScriptJS() { alert('inside functionFromScriptJS'); } iframe.html: <html> <head> <script language=Javascript
Is it possible to use libxml with unicode? For example the xmlParseDoc function takes
This example is from php.net: <?php function Test() { static $a = 0; echo
foreach($arrayOne as $value){ do function } In the above example, I'd like to pass
I've seen a lot of example c++ code that wraps function calls in a
How do I make the below function more dynamic for example commentLink and commentContainer
I'd like a simple example of exporting a function from a C++ Windows DLL.
I'm looking for a method (or function) to strip out the example.ext part of
I need a function that I can call when somthing is done, for example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.