Learning Powershell. Getting this error for custom attribute 'CmdletBidning'

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of CloudItgirl CloudItgirl 5 days, 19 hours ago.

  • Author
    Posts
  • #58261
    Profile photo of CloudItgirl
    CloudItgirl
    Participant

    Hello,
    I am learning powershell and doing this exercise by following some training videos from Lynda.com
    https://www.lynda.com/PowerShell-tutorials/Test-functions-parameters/184167/190640-4.html
    They use PS v3 in the training. I have Pwerhsell version 5.1.14965.1001

    it gives me this error. Why? Googled it and it didn't help me to resolve it.

    Error: Cannot find the type for custom attribute 'CmdletBidning'. Make sure that the assembly that contains this type is loaded.

    Here is the script that I am writing. 🙂

    function CFCompINfo
    {
    [CmdletBinding()]
    [Alias(hostname)]
    [OutputType([int])]
    [string[]$CommputerName
    [switch]$nameLog
    Param
    (
    # Param1 help description
    [Parameter(Mandatory=$true,
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true,
    Position=0)]
    [string[] $Computername,
    [switch]$nameLog

    )

    BEgin {}
    Process {
    foreach ($computer in $computername)
    {
    write-host $computer
    }

    }

    End {}

    }

    Get-DJOSInfo -computername my-pc
    #Get-DJOSInfo -computername dc1, dc2
    #Get-DJOSInfo computers.txt | Get-DJOSInfo -namelog
    #Get-DJOSInfo -host localhost

  • #58267
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant
  • #58276
    Profile photo of Alex
    Alex
    Participant

    Your error message has "CmdletBinding" with a typo.

    Update the script to have the correct spelling and then re-run the script and try your function.

  • #59310
    Profile photo of CloudItgirl
    CloudItgirl
    Participant

    Thank you! It is working now!

You must be logged in to reply to this topic.