Link to home
Create AccountLog in
Avatar of ivan rosa
ivan rosaFlag for United States of America

asked on

-Programming: Learning about "classes" ...

Hello Folks,

I'm expanding my knowledge in learning classes in powershell... I have written this basic  PS example

class Books {

$books1 = [books]::new()
$books1.title = "Harry Potter"
$ = "JK Rowling"
$books1.pages = 309

$books2 = [books]::new()
$books2.title = "Scott Pilgrim vs. the World"
$ = "Bryan Lee O'Malley"
$books2.pages = 168

$books2 | ? {$_.title -like "*scott*"}

Open in new window

this will display the book from book 2 titled like "scott"...
Does anybody have any idea on how can I tell the program to search within all the books and find any "X" Title... I was thinking "foreach" but i'm not sure I could squeeze it in...? or if you have a c# approach that would be great also :)

Thanks in advance!
Avatar of oBdA

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I would recommend you to read and study  a concrete example that could give you a full scope on how to work with classes on powershell

please follow this link
Avatar of ivan rosa


Thanks for your swift response @oBdA. as usual you are always on point!

Thanks for the tips also as well as @Alfred I appreciate it