Answered by:
Windows 64b and 32b

Question
-
Hello,
Guys I have a little problem with my script, because does not want to work, maybe who knows why and will help me a little?
$komp = "win7lab2", "win7lab1"
$komp2=Get-WmiObject -Class Win32_Processor -ComputerName $komp| where-Object AddressWidth -eq 64| Select-Object PscomputerName
$komp3=Get-WmiObject -Class Win32_Processor -ComputerName $komp| where-Object AddressWidth -eq 32| Select-Object PscomputerName
if (Get-WmiObject -Class Win32_Processor -ComputerName $komp| where-Object AddressWidth -eq 64 )
{ $sourcefile = "\\srvdom1\test\googlechro32.msi"
Copy-Item $sourcefile -Destination "\\$komp3\c$\temp"}
else { $sourcefile = "\\srvdom1\test\googlechro64.msi"
Copy-Item $sourcefile -Destination "\\$komp2\c$\temp"}- Edited by lukas317 Sunday, July 16, 2017 8:37 PM
Sunday, July 16, 2017 8:29 PM
Answers
-
$computers = 'comp1','comp2','comp3','comp4' # and more
Get-WmiObject Win32_Processor -ComputerName $computers| ForEach-Object{
if($_.AddressWidth -eq 64){ Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\$($_.SystemName)\c$\temp" }else{ Copy-Item \\srvdom1\test\googlechro32.msi -Destination "\\$($_.SystemName)\c$\temp" } }
\_(ツ)_/
Sunday, July 16, 2017 9:02 PM -
Sorry. Typo/mistake. It should be $_.SystemName. I fixed my original post.
\_(ツ)_/
- Marked as answer by lukas317 Monday, July 17, 2017 5:04 PM
Monday, July 17, 2017 4:42 PM
All replies
-
$computers = 'comp1','comp2','comp3','comp4' # and more
Get-WmiObject Win32_Processor -ComputerName $computers| ForEach-Object{
if($_.AddressWidth -eq 64){ Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\$($_.SystemName)\c$\temp" }else{ Copy-Item \\srvdom1\test\googlechro32.msi -Destination "\\$($_.SystemName)\c$\temp" } }
\_(ツ)_/
Sunday, July 16, 2017 9:02 PM -
HI,
thanks for your reply, but If I use Your Script I get:
Copy-Item : Can not find the network path.
At line:1 char:1
+ Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\$($_.Name) ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemComman
But If I use:
Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\comp1\c$\temp"
It works properly.
- Edited by lukas317 Monday, July 17, 2017 3:45 PM
Monday, July 17, 2017 3:43 PM -
If the computers re wrong or you are not an admin on the remote sstem then your request won't work.
Test the two items:
\\srvdom1\test\googlechro64.msi
AND
"\\comp1\c$\temp"
One or the other either doesn't exist or you don't have permissions.
Note the error "Copy-Item : Can not find the network path.". You are the only one who can resolve this.
\_(ツ)_/
- Edited by jrv Monday, July 17, 2017 4:00 PM
Monday, July 17, 2017 3:58 PM -
But, when I use
Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\comp1\c$\temp"
Is ok. The second part, when I use name "Comp1" and "comp2" is ok too.
Get-WmiObject Win32_Processor -ComputerName $computers| ForEach-Object{ if($_.AddressWidth -eq 64){ Copy-Item \\srvdom1\test\googlechro64.msi -Destination "\\comp1\c$\temp" }else{ Copy-Item \\srvdom1\test\googlechro32.msi -Destination "\\comp2\c$\temp" } }
Problem is only when I use $($ _. Name). Because when I use write-host $ ($ _. Name) I get name processor, but not name computer.
.
Monday, July 17, 2017 4:36 PM -
Sorry. Typo/mistake. It should be $_.SystemName. I fixed my original post.
\_(ツ)_/
- Marked as answer by lukas317 Monday, July 17, 2017 5:04 PM
Monday, July 17, 2017 4:42 PM -
Ok, for this.
I check and found solution to,
When I Change ($ _. Name) -> $($_.pscomputername) works ok, but Your solution is ok too.Thank you!
- Edited by lukas317 Monday, July 17, 2017 5:07 PM
Monday, July 17, 2017 5:04 PM