Hello-
I am running into a problem when I am piping computer names into a function I put together
I have a list of 88 computers names saved as in a text file. The first 31 come back with the correct data and then the script stalls. Could this WSMan Config issue?
He is the code I am working with.
Any Help would be greatly Appreciated
ipcsv .\computer.csv | get-eddyinventory | exxport.csv .\inv.csv
function Test-PsRemoting { [CmdletBinding()] Param ( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] $computername ) try { $errorActionPreference = “Stop” $result = Invoke-Command -ComputerName $computername { 1 } } catch { Write-Verbose $_ return $false } ## I’ve never seen this happen, but if you want to be ## thorough…. if($result -ne 1) { Write-Verbose “Remoting to $computerName returned an unexpected result.” return $false } $true } Function Get-EddyInventory { # $b | select @{n=”computername”;e={$_.name}} | Get-EddyInventory [CmdletBinding()] Param ( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Object]$Object, [String]$Parameter )#End Param Begin { $ErrorActionPreference = “SilentlyContinue” }#Begin Process { trap { $computer | out-file c:\errors.txt -append continue } $Object | ForEach-Object { if ($Parameter) { $Computer = $_.”$Parameter” $test = Test-PsRemoting -computername $Computer } elseif ($_.ComputerName) { $Computer = $_.ComputerName $test = Test-PsRemoting -computername $Computer } else { $Computer = $_ $test = Test-PsRemoting -computername $Computer } if ($test -eq $true) { $os = Get-WMIObject -Class win32_operatingsystem -comp $Computer -ea stop $cs = Get-WmiObject -Class win32_computersystem -comp $Computer -ea stop $bios =Get-WmiObject -Class Win32_BIOS -Computername $Computer -ea Stop $data = new-object psobject $data | add-member noteproperty ‘Computer Name’ $cs.name $data | add-member noteproperty ‘User Name’ $cs.Username $data | add-member noteproperty ‘Operating System’ $os.caption $data | add-member noteproperty ‘Install Date’ $os.ConvertToDateTime($os.installdate) $data | add-member noteproperty ‘Model’ $cs.model $data | add-member noteproperty ‘Servie Tag’ $bios.SerialNumber $data | add-member noteproperty ‘RAM’ ($CS.TotalPhysicalMemory/1GB -AS [INT]) write $data } else { $computer | out-file c:\errors.txt -append } }#Foreach-Object (Computers) } }