Hello and good evening.
Untill someone much smarter than me comes a long (which wont be long), I can try to point you in the right direction.
You actually have several options here. You can use conditional statements that rely on bools (booleans - just posh way of saying it), and Where-Object combined with some operators.
Let me first post this so it doesnt crash on me (Cracked my screen and its acting wonky). We'll start you off with the Switch Statement. Where if a condition is met, do something.
$computer = (gwmi Win32_ComputerSystem).Manufacturer + " " + (gwmi Win32_ComputerSystem).Model
$drivers = Get-ChildItem \\zapp\pc\!Drivers | Select-Object -ExpandProperty Name
Switch ($drivers){
"$computer" {"Found: $_" }
}
I am back!
So, back to where I left off... You can use the switch statement which will do something when a specific condition is met; in this case, its executing a copy-item from the remote PC onto the local one, once it detected what the string matched what you were looking for. See below:
$computer = (gwmi Win32_ComputerSystem).Manufacturer + " " + (gwmi Win32_ComputerSystem).Model
Switch (Get-ChildItem \\zapp\pc\!Drivers){
"$computer" {Copy-Item -Path $_.FullName -Destination C:\DriverStore }
}
Using the Foreach loop, we can iterate through each file and attempt to match the the value you're passing it using an if statement, executing a Copy-Item on the remote PC onto yours once found.
Foreach($file in (Get-ChildItem \\zapp\pc\!Drivers)){
if($file -match $computer){ Copy-Item -Path $file.FullName -Destination C:\DriverStore}
}
Next, we are just piping the files over to the Where-Object with the help of a -match operator, matching the value specified to it against the objects on the left. A Foreach-Object cmdlet (not to be confused with Foreach) is used at the end with a parameter of -Process to run each element inside the input object. Then copying over from the remote PC to yours the folder that matched your PC.
$computer = (gwmi Win32_ComputerSystem).Manufacturer + " " + (gwmi Win32_ComputerSystem).Model
Get-ChildItem \\zapp\pc\!Drivers | Where-Object {$_.Name -match $computer} |ForEach-Object -process{ Copy-Item -Path $_.fullname -Destination C:\DriverStore}
Hopefully, this makes sense and can get you on the right track. There are a couple of others I didnt mention just to keep it simple but, @Lee_Daily did mention the .Where() method which could be used in this situation as well.
.Where()collection method. [grin]