I'm trying to create a custom object but receive error. Does anyone have ideas on how to deal with this issue?
$tempObject = New-Object System.Object
Add-Member -inputobject $tempObject -type NoteProperty -name Name -value ""
Add-Member -inputobject $tempObject -type NoteProperty -name account status -value ""
Add-Member -inputobject $tempObject -type NoteProperty -name OU -value ""
Add-Member -inputobject $tempObject -type NoteProperty -name Last Logon -value ""
Add-Member : The SecondValue parameter is not necessary for a member of type "NoteProperty", and should not be specified. Do not specify the SecondValue parameter when you add members of this type.
Where you have spaces in your strings, put them in quotes (single or double):
Update
Per @wannabeprogrammer's comment below, a shorthand way of achieving the above would be:
...or to get exactly the same (i.e. so a
compare-object
of the two methods shows no difference between the objects being created).See what I mean by running the above snippets, then the below: