I am new to the Powershell world. Below is my first script
$sServer = "Fully.Qualified.Computer.Name" $os = Get-WmiObject -class Win32_OperatingSystem -computername $sServer $object = New-Object –TypeNamePSObject $object | Add-Member –MemberTypeNoteProperty –Name OSBuild –Value $os.BuildNumber $object | Add-Member –MemberTypeNoteProperty –Name OSVersion –Value $os.Version $object | Add-Member –MemberTypeNoteProperty –Name BIOSSerial –Value $bios.SerialNumber Write-Output $object
When I run this script in PowershellISE, I get the following error.
New-Object : A parameter cannot be found that matches parameter name 'TypeNamePSObject'. At C:\Users\someone\Desktop\SchwansScript.ps1:27 char:22 + $object = New-Object –TypeNamePSObject + ~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [New-Object],ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Unfortunately for me, it seems like "A parameter cannot be found..." is an extremely common and ambiguous error, saying that there is a problem, but never where. I was wondering if anyone could tell why this error is occuring. Oh, and I'm on Windows 7 and my PS Version is
PS C:\Users\someone> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 4 0 -1 -1
Any help on this is greatly appreciated.