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
21 Views
Last Modified: 2016-11-26
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
  • 2
4 Comments
 
LVL 68

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 83

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now