Solved

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

Posted on 2016-11-20
4
79 Views
Last Modified: 2016-12-21
Hello,
I am learning powershell and doing this exercise by following some training videos. But it gives me this error. Why? Googled it and it didn't help me to resolve it.

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


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
0
Comment
Question by:creative555
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 41895112
All parts before the param belong inside the {b]param[/b].
0
 

Author Comment

by:creative555
ID: 41895231
hm. THey are in inside {......Besides I also tried inserting snippet from Powershell and everying seems to be fine but still getting the error.
Could you please give an example how it should be. L


Function Get-DJOSInfo {
[CmdletBidning()]
    param([Parameter(Mandatory=$true,
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
    [Alias('hostname')]
    [string[]$CommputerName,
    [switch]$nameLog
)
BEgin {}
Process {
    foreach ($computer in $computername)
{
#write-host $computer  
    $os = get-wmiobject -computerName $Computer -class Win32_OperatingSystem | select Caption,Build,OSARchitecture,ServicePackMajorVErsion
    $bios = get-wmiObject -computerName $Computer -class Win32_BIOS | select SerialNumber
    $processor = get-WMIObject -computerName $Computer -class Win32_Processor | select AddressWidth -first 1
}

}

End {}


}
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 41895409
* It's "CmdletBinding", not "CmdletBidning"
* "[string[]$ComputerName" is missing a closing square bracket: "[string[]]$ComputerName",
* In the Param section, you had "$CommputerName" instead of "$ComputerName"
* The function is generating no pipeline output.
* Convention for Powershell scripts is Pascal Case, see "Strongly Encouraged Development Guidelines", https://msdn.microsoft.com/en-us/library/dd878270(v=vs.85).aspx
It's best to get used to it form the very beginning (and so is consistent indentation).
* Using Aliases is fine in the Powershell prompt, but in scripts, you should always use the full names - you'll never know when they might be running on a machine where somebody redefined an alias (somebody might for example consider "dir" a good abbreviation for "Delete Immediate Recursive" ...)
Function Get-DJOSInfo {
[CmdletBinding()]
Param(
	[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
	[Alias('hostname')]
	[string[]]$ComputerName,
	[switch]$NameLog
)
	Begin {}
	Process {
		ForEach ($Computer in $ComputerName) {
			#Write-Host $Computer
			$OS = Get-WmiObject -ComputerName $Computer -Class Win32_OperatingSystem | Select-Object Caption, Build, OSArchitecture, ServicePackMajorVersion
			$Bios = Get-WmiObject -ComputerName $Computer -Class Win32_BIOS | Select-Object SerialNumber
			$Processor = Get-WmiObject -ComputerName $Computer -Class Win32_Processor | Select-Object AddressWidth -First 1
			Write-Host "---- OS ----" -Fore Yellow
			$OS
			Write-Host "---- Bios ----" -Fore Yellow
			$Bios.SerialNumber
			Write-Host "---- Processor ----" -Fore Yellow
			$Processor.AddressWidth
		}
	}
	End {}
}

Get-DJOSInfo -ComputerName $ENV:ComputerName

Open in new window

0
 

Author Closing Comment

by:creative555
ID: 41902724
Yes!!  It's "CmdletBinding", not "CmdletBidning" Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question