Error catching some info from remote computers who dont answer to ping The Next CEO of Stack OverflowLogical drive infoAdd extra properties to an object?Invalid Namespace when automating Get-WMIObjectTrimStart/ForEach on multiple linesPowershell Export-Csv gives undesired resultPowershell script to audit hosts file on all hosts on a domain but doing OU by OUIssue with output of Powershell functionGet Name and DHCP status By PowershellGather Scheduled Task information through powershell v2Script to get Bitlocker protector info then backup to AD

Why am I allowed to create multiple unique pointers from a single object?

Why does standard notation not preserve intervals (visually)

Would a completely good Muggle be able to use a wand?

MessageLevel in QGIS3

How do I reset passwords on multiple websites easily?

Can we say or write : "No, it'sn't"?

What is "(CFMCC)" on an ILS approach chart?

Do I need to enable Dev Hub in my PROD Org?

If a black hole is created from light, can this black hole then move at speed of light?

Complex fractions

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

How does the mv command work with external drives?

How did people program for Consoles with multiple CPUs?

Why do airplanes bank sharply to the right after air-to-air refueling?

Is there a way to save my career from absolute disaster?

How to avoid supervisors with prejudiced views?

What happened in Rome, when the western empire "fell"?

Anatomically Correct Strange Women In Ponds Distributing Swords

Is "for causing autism in X" grammatical?

Unreliable Magic - Is it worth it?

In excess I'm lethal

How do scammers retract money, while you can’t?

What benefits would be gained by using human laborers instead of drones in deep sea mining?



Error catching some info from remote computers who dont answer to ping



The Next CEO of Stack OverflowLogical drive infoAdd extra properties to an object?Invalid Namespace when automating Get-WMIObjectTrimStart/ForEach on multiple linesPowershell Export-Csv gives undesired resultPowershell script to audit hosts file on all hosts on a domain but doing OU by OUIssue with output of Powershell functionGet Name and DHCP status By PowershellGather Scheduled Task information through powershell v2Script to get Bitlocker protector info then backup to AD










1















With little knowledge, I managed to assemble the script shown below, to obtain the amount of ram memory that the teams registered in the AD of the company have.






#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"





The script works, but on some computers that do not respond to the ping, it throws the error:



Get-WmiObject : El servidor RPC no está disponible. (Excepción de HRESULT: 0x800706BA)
En C:UsersfcaballeDesktopGetRam_AD-Source.ps1: 25 Carácter: 30
+ $colItems = get-wmiobject <<<< -class "Win32_ComputerSystem" -namespace "rootCIMV2" -comput
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


How I can avoid this error and simply get a "Not Pingable" definition?










share|improve this question
























  • Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

    – mhhollomon
    Mar 21 at 17:10











  • put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

    – Lee_Dailey
    Mar 21 at 17:28















1















With little knowledge, I managed to assemble the script shown below, to obtain the amount of ram memory that the teams registered in the AD of the company have.






#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"





The script works, but on some computers that do not respond to the ping, it throws the error:



Get-WmiObject : El servidor RPC no está disponible. (Excepción de HRESULT: 0x800706BA)
En C:UsersfcaballeDesktopGetRam_AD-Source.ps1: 25 Carácter: 30
+ $colItems = get-wmiobject <<<< -class "Win32_ComputerSystem" -namespace "rootCIMV2" -comput
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


How I can avoid this error and simply get a "Not Pingable" definition?










share|improve this question
























  • Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

    – mhhollomon
    Mar 21 at 17:10











  • put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

    – Lee_Dailey
    Mar 21 at 17:28













1












1








1








With little knowledge, I managed to assemble the script shown below, to obtain the amount of ram memory that the teams registered in the AD of the company have.






#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"





The script works, but on some computers that do not respond to the ping, it throws the error:



Get-WmiObject : El servidor RPC no está disponible. (Excepción de HRESULT: 0x800706BA)
En C:UsersfcaballeDesktopGetRam_AD-Source.ps1: 25 Carácter: 30
+ $colItems = get-wmiobject <<<< -class "Win32_ComputerSystem" -namespace "rootCIMV2" -comput
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


How I can avoid this error and simply get a "Not Pingable" definition?










share|improve this question
















With little knowledge, I managed to assemble the script shown below, to obtain the amount of ram memory that the teams registered in the AD of the company have.






#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"





The script works, but on some computers that do not respond to the ping, it throws the error:



Get-WmiObject : El servidor RPC no está disponible. (Excepción de HRESULT: 0x800706BA)
En C:UsersfcaballeDesktopGetRam_AD-Source.ps1: 25 Carácter: 30
+ $colItems = get-wmiobject <<<< -class "Win32_ComputerSystem" -namespace "rootCIMV2" -comput
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


How I can avoid this error and simply get a "Not Pingable" definition?






#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"





#Import AD's module
Import-Module ActiveDirectory

#Grab a list of computer names from Active Directory (in City 3)
$ComputerList = Get-ADComputer -Filter * -searchbase "OU=Workstations,OU=Machines,OU=CUSTOM,DC=xxxxxx,DC=xxx" | select-object Name

#Output file
$csvOutput = 'C:TempRAMRAM List.csv'
#Deletes the output file if it exists
If (Test-Path $csvOutput)
Remove-Item $csvOutput

#Fills in the first line of the output file with the headline
Add-Content -Path $csvOutput -Value "Name,Pingable,RAM"

#Go through each computer in the List
$ComputerList | %

#Put the current computer name in a variable called $ComputerName
$ComputerName = $_.Name

#Ping the remote computer
$Ping = Test-Connection $ComputerName -Count 2 -EA Silentlycontinue

$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "rootCIMV2" -computername $ComputerName

If ($ping)
#If Ping is successfull, try to grab IE's version and put it in $IEVersionString's variable.
#$IEVersionString = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("\$ComputerNameC$Program FilesInternet Exploreriexplore.exe").Fileversion
foreach ($objItem in $colItems)
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)

#Edit the CSV file and add an extra line with the results of the above operations (Ping/IE Version)
Add-Content -Path $csvOutput -Value "$($ComputerName),YES,$($displayGB)"
#Write console output and show what computer is being processed and IE's version
Write-Host "$($ComputerName) - $($displayGB) "GB""



Else
#If we're here, the machine is NOT pingable
#Edit the CSV file and add an extra line with the results of the Ping (No)
Add-Content -Path $csvOutput -Value "$($ComputerName),NO,N/A"
#Write console output and show what computer is being processed and state that it's not pingable
Write-Host "$($ComputerName) - Not Pingable"






powershell scripting rpc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 18:58







user10976548

















asked Mar 21 at 16:56









Facundo CaballeFacundo Caballe

62




62












  • Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

    – mhhollomon
    Mar 21 at 17:10











  • put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

    – Lee_Dailey
    Mar 21 at 17:28

















  • Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

    – mhhollomon
    Mar 21 at 17:10











  • put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

    – Lee_Dailey
    Mar 21 at 17:28
















Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

– mhhollomon
Mar 21 at 17:10





Welcome to the site. The self introduction really isn't necessary. And remember, the question and answer will be around for years to help others with a similar problem. Updating your profile is a better way to introduce yourself.

– mhhollomon
Mar 21 at 17:10













put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

– Lee_Dailey
Mar 21 at 17:28





put your WMI call in the if ($Ping) so that is only runs that code if the ping works. [grin] ///// also, instead of building the CSV by hand, build a custom object that holds the properties you want. then send that to a CSV file with the Export-CSV cmdlet.

– Lee_Dailey
Mar 21 at 17:28












1 Answer
1






active

oldest

votes


















0














here's one way to do this. [grin] i did not use Invoke-Command to get things to run in parallel since you did not indicate that such was needed. if you DO need more speed, then convert the foreach into a scriptblock and call that with Invoke-Command and the list of accessible systems.



what it does ...



  • creates a fake list of computers

    that should be done via Import-CSV or with something like Get-ADComputer.

  • sets the "not reachable" message

  • iterates thru the system list

  • checks for "is it there?"

  • if it responds, then get the RAM & IE info

  • if it does NOT respond, set the two items to the "not reachable" message

  • builds a custom object that will export to a CSV neatly

  • sends the object out to the $Results variable

  • finishes the iteration

  • shows the $Results collection on screen

  • sends that collection to the CSV file

here's the code ...



# fake reading in a CSV file
# in real life, use Import-CSV [or Get-ADComputer]
$ComputerList = @"
ComputerName
LocalHost
10.0.0.1
127.0.0.1
BetterNotBeThere
$env:COMPUTERNAME
"@ | ConvertFrom-Csv

$Offline = '__Offline__'

$Results = foreach ($CL_Item in $ComputerList)

if (Test-Connection -ComputerName $CL_Item.ComputerName -Count 1 -Quiet)

$GCIMI_Params = @
ClassName = 'CIM_ComputerSystem'
ComputerName = $CL_Item.ComputerName

$TotalRAM_GB = [math]::Round((Get-CimInstance @GCIMI_Params).TotalPhysicalMemory / 1GB, 0)

$GCI_Params = @
Path = "\$($CL_Item.ComputerName)c$Program FilesInternet Exploreriexplore.exe"

$IE_Version = (Get-ChildItem @GCI_Params).
VersionInfo.
ProductVersion

else

$TotalRAM_GB = $IE_Version = $Offline


[PSCustomObject]@
ComputerName = $CL_Item.ComputerName
TotalRAM_GB = $TotalRAM_GB
IE_Version = $IE_Version



# on screen
$Results

# to CSV
$Results |
Export-Csv -LiteralPath "$env:TEMPFacundoCaballe_Ram_IE_Report.csv" -NoTypeInformation


onscreen output ...



ComputerName TotalRAM_GB IE_Version 
------------ ----------- ----------
LocalHost 8 11.00.9600.16428
10.0.0.1 __Offline__ __Offline__
127.0.0.1 8 11.00.9600.16428
BetterNotBeThere __Offline__ __Offline__
[MySysName] 8 11.00.9600.16428


CSV file content ...



"ComputerName","TotalRAM_GB","IE_Version"
"LocalHost","8","11.00.9600.16428"
"10.0.0.1","__Offline__","__Offline__"
"127.0.0.1","8","11.00.9600.16428"
"BetterNotBeThere","__Offline__","__Offline__"
"[MySysName]","8","11.00.9600.16428"





share|improve this answer























  • Lee_dailey. Thanks for your answer.

    – Facundo Caballe
    Mar 21 at 18:45











  • @FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

    – Lee_Dailey
    Mar 21 at 19:22











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285552%2ferror-catching-some-info-from-remote-computers-who-dont-answer-to-ping%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














here's one way to do this. [grin] i did not use Invoke-Command to get things to run in parallel since you did not indicate that such was needed. if you DO need more speed, then convert the foreach into a scriptblock and call that with Invoke-Command and the list of accessible systems.



what it does ...



  • creates a fake list of computers

    that should be done via Import-CSV or with something like Get-ADComputer.

  • sets the "not reachable" message

  • iterates thru the system list

  • checks for "is it there?"

  • if it responds, then get the RAM & IE info

  • if it does NOT respond, set the two items to the "not reachable" message

  • builds a custom object that will export to a CSV neatly

  • sends the object out to the $Results variable

  • finishes the iteration

  • shows the $Results collection on screen

  • sends that collection to the CSV file

here's the code ...



# fake reading in a CSV file
# in real life, use Import-CSV [or Get-ADComputer]
$ComputerList = @"
ComputerName
LocalHost
10.0.0.1
127.0.0.1
BetterNotBeThere
$env:COMPUTERNAME
"@ | ConvertFrom-Csv

$Offline = '__Offline__'

$Results = foreach ($CL_Item in $ComputerList)

if (Test-Connection -ComputerName $CL_Item.ComputerName -Count 1 -Quiet)

$GCIMI_Params = @
ClassName = 'CIM_ComputerSystem'
ComputerName = $CL_Item.ComputerName

$TotalRAM_GB = [math]::Round((Get-CimInstance @GCIMI_Params).TotalPhysicalMemory / 1GB, 0)

$GCI_Params = @
Path = "\$($CL_Item.ComputerName)c$Program FilesInternet Exploreriexplore.exe"

$IE_Version = (Get-ChildItem @GCI_Params).
VersionInfo.
ProductVersion

else

$TotalRAM_GB = $IE_Version = $Offline


[PSCustomObject]@
ComputerName = $CL_Item.ComputerName
TotalRAM_GB = $TotalRAM_GB
IE_Version = $IE_Version



# on screen
$Results

# to CSV
$Results |
Export-Csv -LiteralPath "$env:TEMPFacundoCaballe_Ram_IE_Report.csv" -NoTypeInformation


onscreen output ...



ComputerName TotalRAM_GB IE_Version 
------------ ----------- ----------
LocalHost 8 11.00.9600.16428
10.0.0.1 __Offline__ __Offline__
127.0.0.1 8 11.00.9600.16428
BetterNotBeThere __Offline__ __Offline__
[MySysName] 8 11.00.9600.16428


CSV file content ...



"ComputerName","TotalRAM_GB","IE_Version"
"LocalHost","8","11.00.9600.16428"
"10.0.0.1","__Offline__","__Offline__"
"127.0.0.1","8","11.00.9600.16428"
"BetterNotBeThere","__Offline__","__Offline__"
"[MySysName]","8","11.00.9600.16428"





share|improve this answer























  • Lee_dailey. Thanks for your answer.

    – Facundo Caballe
    Mar 21 at 18:45











  • @FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

    – Lee_Dailey
    Mar 21 at 19:22















0














here's one way to do this. [grin] i did not use Invoke-Command to get things to run in parallel since you did not indicate that such was needed. if you DO need more speed, then convert the foreach into a scriptblock and call that with Invoke-Command and the list of accessible systems.



what it does ...



  • creates a fake list of computers

    that should be done via Import-CSV or with something like Get-ADComputer.

  • sets the "not reachable" message

  • iterates thru the system list

  • checks for "is it there?"

  • if it responds, then get the RAM & IE info

  • if it does NOT respond, set the two items to the "not reachable" message

  • builds a custom object that will export to a CSV neatly

  • sends the object out to the $Results variable

  • finishes the iteration

  • shows the $Results collection on screen

  • sends that collection to the CSV file

here's the code ...



# fake reading in a CSV file
# in real life, use Import-CSV [or Get-ADComputer]
$ComputerList = @"
ComputerName
LocalHost
10.0.0.1
127.0.0.1
BetterNotBeThere
$env:COMPUTERNAME
"@ | ConvertFrom-Csv

$Offline = '__Offline__'

$Results = foreach ($CL_Item in $ComputerList)

if (Test-Connection -ComputerName $CL_Item.ComputerName -Count 1 -Quiet)

$GCIMI_Params = @
ClassName = 'CIM_ComputerSystem'
ComputerName = $CL_Item.ComputerName

$TotalRAM_GB = [math]::Round((Get-CimInstance @GCIMI_Params).TotalPhysicalMemory / 1GB, 0)

$GCI_Params = @
Path = "\$($CL_Item.ComputerName)c$Program FilesInternet Exploreriexplore.exe"

$IE_Version = (Get-ChildItem @GCI_Params).
VersionInfo.
ProductVersion

else

$TotalRAM_GB = $IE_Version = $Offline


[PSCustomObject]@
ComputerName = $CL_Item.ComputerName
TotalRAM_GB = $TotalRAM_GB
IE_Version = $IE_Version



# on screen
$Results

# to CSV
$Results |
Export-Csv -LiteralPath "$env:TEMPFacundoCaballe_Ram_IE_Report.csv" -NoTypeInformation


onscreen output ...



ComputerName TotalRAM_GB IE_Version 
------------ ----------- ----------
LocalHost 8 11.00.9600.16428
10.0.0.1 __Offline__ __Offline__
127.0.0.1 8 11.00.9600.16428
BetterNotBeThere __Offline__ __Offline__
[MySysName] 8 11.00.9600.16428


CSV file content ...



"ComputerName","TotalRAM_GB","IE_Version"
"LocalHost","8","11.00.9600.16428"
"10.0.0.1","__Offline__","__Offline__"
"127.0.0.1","8","11.00.9600.16428"
"BetterNotBeThere","__Offline__","__Offline__"
"[MySysName]","8","11.00.9600.16428"





share|improve this answer























  • Lee_dailey. Thanks for your answer.

    – Facundo Caballe
    Mar 21 at 18:45











  • @FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

    – Lee_Dailey
    Mar 21 at 19:22













0












0








0







here's one way to do this. [grin] i did not use Invoke-Command to get things to run in parallel since you did not indicate that such was needed. if you DO need more speed, then convert the foreach into a scriptblock and call that with Invoke-Command and the list of accessible systems.



what it does ...



  • creates a fake list of computers

    that should be done via Import-CSV or with something like Get-ADComputer.

  • sets the "not reachable" message

  • iterates thru the system list

  • checks for "is it there?"

  • if it responds, then get the RAM & IE info

  • if it does NOT respond, set the two items to the "not reachable" message

  • builds a custom object that will export to a CSV neatly

  • sends the object out to the $Results variable

  • finishes the iteration

  • shows the $Results collection on screen

  • sends that collection to the CSV file

here's the code ...



# fake reading in a CSV file
# in real life, use Import-CSV [or Get-ADComputer]
$ComputerList = @"
ComputerName
LocalHost
10.0.0.1
127.0.0.1
BetterNotBeThere
$env:COMPUTERNAME
"@ | ConvertFrom-Csv

$Offline = '__Offline__'

$Results = foreach ($CL_Item in $ComputerList)

if (Test-Connection -ComputerName $CL_Item.ComputerName -Count 1 -Quiet)

$GCIMI_Params = @
ClassName = 'CIM_ComputerSystem'
ComputerName = $CL_Item.ComputerName

$TotalRAM_GB = [math]::Round((Get-CimInstance @GCIMI_Params).TotalPhysicalMemory / 1GB, 0)

$GCI_Params = @
Path = "\$($CL_Item.ComputerName)c$Program FilesInternet Exploreriexplore.exe"

$IE_Version = (Get-ChildItem @GCI_Params).
VersionInfo.
ProductVersion

else

$TotalRAM_GB = $IE_Version = $Offline


[PSCustomObject]@
ComputerName = $CL_Item.ComputerName
TotalRAM_GB = $TotalRAM_GB
IE_Version = $IE_Version



# on screen
$Results

# to CSV
$Results |
Export-Csv -LiteralPath "$env:TEMPFacundoCaballe_Ram_IE_Report.csv" -NoTypeInformation


onscreen output ...



ComputerName TotalRAM_GB IE_Version 
------------ ----------- ----------
LocalHost 8 11.00.9600.16428
10.0.0.1 __Offline__ __Offline__
127.0.0.1 8 11.00.9600.16428
BetterNotBeThere __Offline__ __Offline__
[MySysName] 8 11.00.9600.16428


CSV file content ...



"ComputerName","TotalRAM_GB","IE_Version"
"LocalHost","8","11.00.9600.16428"
"10.0.0.1","__Offline__","__Offline__"
"127.0.0.1","8","11.00.9600.16428"
"BetterNotBeThere","__Offline__","__Offline__"
"[MySysName]","8","11.00.9600.16428"





share|improve this answer













here's one way to do this. [grin] i did not use Invoke-Command to get things to run in parallel since you did not indicate that such was needed. if you DO need more speed, then convert the foreach into a scriptblock and call that with Invoke-Command and the list of accessible systems.



what it does ...



  • creates a fake list of computers

    that should be done via Import-CSV or with something like Get-ADComputer.

  • sets the "not reachable" message

  • iterates thru the system list

  • checks for "is it there?"

  • if it responds, then get the RAM & IE info

  • if it does NOT respond, set the two items to the "not reachable" message

  • builds a custom object that will export to a CSV neatly

  • sends the object out to the $Results variable

  • finishes the iteration

  • shows the $Results collection on screen

  • sends that collection to the CSV file

here's the code ...



# fake reading in a CSV file
# in real life, use Import-CSV [or Get-ADComputer]
$ComputerList = @"
ComputerName
LocalHost
10.0.0.1
127.0.0.1
BetterNotBeThere
$env:COMPUTERNAME
"@ | ConvertFrom-Csv

$Offline = '__Offline__'

$Results = foreach ($CL_Item in $ComputerList)

if (Test-Connection -ComputerName $CL_Item.ComputerName -Count 1 -Quiet)

$GCIMI_Params = @
ClassName = 'CIM_ComputerSystem'
ComputerName = $CL_Item.ComputerName

$TotalRAM_GB = [math]::Round((Get-CimInstance @GCIMI_Params).TotalPhysicalMemory / 1GB, 0)

$GCI_Params = @
Path = "\$($CL_Item.ComputerName)c$Program FilesInternet Exploreriexplore.exe"

$IE_Version = (Get-ChildItem @GCI_Params).
VersionInfo.
ProductVersion

else

$TotalRAM_GB = $IE_Version = $Offline


[PSCustomObject]@
ComputerName = $CL_Item.ComputerName
TotalRAM_GB = $TotalRAM_GB
IE_Version = $IE_Version



# on screen
$Results

# to CSV
$Results |
Export-Csv -LiteralPath "$env:TEMPFacundoCaballe_Ram_IE_Report.csv" -NoTypeInformation


onscreen output ...



ComputerName TotalRAM_GB IE_Version 
------------ ----------- ----------
LocalHost 8 11.00.9600.16428
10.0.0.1 __Offline__ __Offline__
127.0.0.1 8 11.00.9600.16428
BetterNotBeThere __Offline__ __Offline__
[MySysName] 8 11.00.9600.16428


CSV file content ...



"ComputerName","TotalRAM_GB","IE_Version"
"LocalHost","8","11.00.9600.16428"
"10.0.0.1","__Offline__","__Offline__"
"127.0.0.1","8","11.00.9600.16428"
"BetterNotBeThere","__Offline__","__Offline__"
"[MySysName]","8","11.00.9600.16428"






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 18:05









Lee_DaileyLee_Dailey

2,5561811




2,5561811












  • Lee_dailey. Thanks for your answer.

    – Facundo Caballe
    Mar 21 at 18:45











  • @FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

    – Lee_Dailey
    Mar 21 at 19:22

















  • Lee_dailey. Thanks for your answer.

    – Facundo Caballe
    Mar 21 at 18:45











  • @FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

    – Lee_Dailey
    Mar 21 at 19:22
















Lee_dailey. Thanks for your answer.

– Facundo Caballe
Mar 21 at 18:45





Lee_dailey. Thanks for your answer.

– Facundo Caballe
Mar 21 at 18:45













@FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

– Lee_Dailey
Mar 21 at 19:22





@FacundoCaballe - you are most welcome! glad to help a little bit ... [grin]

– Lee_Dailey
Mar 21 at 19:22



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285552%2ferror-catching-some-info-from-remote-computers-who-dont-answer-to-ping%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현