Solved

I need a script that will generate a user report with certain information

Posted on 2013-11-06
42
348 Views
Last Modified: 2014-01-03
I'm trying to generate a report with the following information:

computer, username, Operating System, Architecture (i.e. 32-bit or 64-bit).

Can anyone help? I have managed to generate a user to machine report using:

:CHECK
echo Checking Connection ...
ping %1 -n 1  | findstr "TTL=" >nul && GOTO MAIN || GOTO ERROR
GOTO END

:ERROR
echo Device Unreachable
GOTO END

:MAIN

wmic /node: "%1" computersystem get username

GOTO END

:END


I put this in a batch file called who.bat and run who.bat 'computername'. But that only returns one computer at a time - which would take FORever. Any ideas? I'd
0
Comment
Question by:roycbene
  • 18
  • 18
  • 2
  • +1
42 Comments
 
LVL 20

Expert Comment

by:netcmh
ID: 39628581
You could try a different approach using powershell. Please see this page for step by step instructions and the script itself: http://www.signalwarrant.com/2013/09/18/computer-inventory-script-powershell/

More guidance and tweaks at http://markpashby.com/blog/?p=79

Another route is to use a login script to pull all the information, such as in http://www.lazysystemadmin.com/2010/06/login-script-inventory-collection-for.html
0
 
LVL 3

Author Comment

by:roycbene
ID: 39628714
@ netcmh,

The script works fine until it should generate the pcinventory.csv file. In other words, it displays the progress bars and populates the live and dead pc text files. It also gets to the end and says it finishes. However, it does not create the final report. There is an error occurring somewhere. I noticed that the script is set to continue silently through errors. What can I set it to in order to see where the break is occurring? Thanks in advance for your help.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39628740
Do you run a logon script for all users, you could simply add command to the end of that.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39628741
Yes, but we do not have time to go through 3,000 text files. netcmh's solution is solid, I just need to figure out where the break is.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39628756
@ netcmh,

I do believe we figured it out. The script is at 44% now and collecting hardware info. I'll keep you 'posted' (pun intended) as to how things go. Thanks again for your help.

-R
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39628763
Odd, my script lines above didn't make it.   Anyway if that is an option we can add some lines to a VBScript or batch script to record last user, computer, etc. to text file(s), e.g. to \\server\share\users\username.txt, \\server\share\pc\computername.txt etc. to get an easy log of who was on each computer and user.

Is this on an Active Directory domain too as various information can be pulled from AD.

Steve

[Edit] - Your posts above crossed with mine, will leave at that!
0
 
LVL 3

Author Comment

by:roycbene
ID: 39628867
@ netcmh,

The script gets through all the way to checking hardware. It seems to finish, but exports no csv file. Can you please assist?
0
 
LVL 3

Author Comment

by:roycbene
ID: 39630595
Still need help, guys. Any thoughts???
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39631024
Sorry about the silence. Was offsite and had no access out.

Do you get to the "Script is complete, the results are here:" portion?
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39631093
Somethings to remember to help in troubleshooting powershell scripts:

use the write-host command to give feedback
write an event to the Event log when something occurs in the script as a checkpoint mechanism using Write-EventLog
or use debug as in http://technet.microsoft.com/en-us/library/ff730925.aspx
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39631150
Silly question, but you do have write access to C:\scripts\ or the location you decided on the $exportLocation variable, right?
0
 
LVL 3

Author Comment

by:roycbene
ID: 39631220
@netcmh...

No worries at all for the silence. I've been up to my neck today, myself.

To answer your first and last question; yes to both. I am getting script is finished. But, since it's set to run silently, I wouldn't expect otherwise. I also do have write permissions to the location. It seems to choke on pulling the machine information. I tried the other script too (the one that builds the spreadsheet), and it populates on a home, then just chokes and gets stuck. I don't  understand.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39631222
On a home = one machine. Stupid autocorrect.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39631280
After line 41's $i = 0;
add this line:
write-host "increment#" $i

&

After line 83's $OutputObj | Export-Csv $exportLocation -Append
add this line:
write-host "Completed" $Computer

Run the script again, and if it says Completed and the computername, and increment# 2, then the loop is incrementing and that the problem could be access to the next computer.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39631572
@ netcmh

Ok, so that worked a treat as far as letting me see if the machines were actually cycling through and completing. They all complete, but no csv file. I don't get it. Everything seems to complete beautifully, but no .csv populates. Ideas? I've tried pre-creating the  file to see if it would populate it, but no luck.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39631599
So, you see the script cycle through your entire list, but it still doesn't create the file?

Can you check to see if the file exists during every increment? Could it be that it gets deleted at the end of the script run?
0
 
LVL 3

Author Comment

by:roycbene
ID: 39631652
I keep the folder open (scripts folder) when I'm running it, but it doesn't appear that the file ever even gets created. Weird...
0
 
LVL 3

Author Comment

by:roycbene
ID: 39631658
I've even done just one machine at a time and it doesn't create the file. It's definitely not a permissions issue. I'm logged on as the domain admin.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39633398
@netcmh .. should I post the final script here and maybe you, or someone, can see why it's not creating the file?
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633405
Let's do that
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Author Comment

by:roycbene
ID: 39633421
$erroractionpreference = "SilentlyContinue"

# TXT file containing the computers your pinging
$testcomputers = gc -Path "C:\scripts\computers.txt"

$test_computer_count = $testcomputers.Length;
$x = 0;

write-host -foregroundcolor cyan ""
write-host -foregroundcolor cyan "Testing $test_computer_count computers, this may take a while."

foreach ($computer in $testcomputers) {
        # I only send 2 echo requests to speed things up, if you want the defaut 4
        # delete the -count 2 portion
   if (Test-Connection -ComputerName $computer -Quiet -count 2){
        Add-Content -value $computer -path c:\scripts\livePCs.txt
        }else{
        Add-Content -value $computer -path c:\scripts\deadPCs.txt
        }
    $testcomputer_progress = [int][Math]::Ceiling((($x / $test_computer_count) * 100))
      
    Write-Progress  "Testing Connections" -PercentComplete $testcomputer_progress -Status "Percent Complete - $testcomputer_progress%" -Id 1;
      Sleep(1);
    $x++;

}

write-host -foregroundcolor cyan ""
write-host -foregroundcolor cyan "Testing Connection complete"
write-host -foregroundcolor cyan ""

$ComputerName = gc -Path "C:\scripts\livePCs.txt"

$computer_count = $ComputerName.Length;

$exportLocation = "C:\scripts\pcInventory.csv"
$i = 0;
write-host "increment#" $i
 foreach ($Computer in $ComputerName){
   $Bios =get-wmiobject win32_bios -Computername $Computer
   $Hardware = get-wmiobject Win32_computerSystem -Computername $Computer
   $Sysbuild = get-wmiobject Win32_WmiSetting -Computername $Computer
   $OS = gwmi Win32_OperatingSystem -Computername $Computer
   $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
   $driveSpace = gwmi win32_volume -computername $Computer -Filter 'drivetype = 3' |
   select PScomputerName, driveletter, label, @{LABEL='GBfreespace';EXPRESSION={"{0:N2}" -f($_.freespace/1GB)} } |
   Where-Object { $_.driveletter -match "C:" }
   $cpu = Get-WmiObject Win32_Processor  -computername $computer
   $username = Get-ChildItem "\\$computer\c$\Users" | Sort-Object LastWriteTime -Descending | Select Name, LastWriteTime -first 1
   $totalMemory = [math]::round($Hardware.TotalPhysicalMemory/1024/1024/1024, 2)
   $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)

   #write-host -foregroundcolor yellow "Found $computer"
   $computer_progress = [int][Math]::Ceiling((($i / $computer_count) * 100))
      
    Write-Progress  "Gathering Hardware Info" -PercentComplete $computer_progress -Status "Percent Complete - $computer_progress%" -Id 1;
      Sleep(1);
    $i++;
   foreach ($Network in $Networks) {
    $IPAddress  = $Network.IpAddress[0]
    $MACAddress  = $Network.MACAddress
    $systemBios = $Bios.serialnumber
    $OutputObj  = New-Object -Type PSObject
    $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
    $OutputObj | Add-Member -MemberType NoteProperty -Name Manufacturer -Value $Hardware.Manufacturer
    $OutputObj | Add-Member -MemberType NoteProperty -Name Model -Value $Hardware.Model
    $OutputObj | Add-Member -MemberType NoteProperty -Name CPU_Info -Value $cpu.Name
    $OutputObj | Add-Member -MemberType NoteProperty -Name SystemType -Value $Hardware.SystemType
    $OutputObj | Add-Member -MemberType NoteProperty -Name BuildVersion -Value $SysBuild.BuildVersion
    $OutputObj | Add-Member -MemberType NoteProperty -Name OS -Value $OS.Caption
    $OutputObj | Add-Member -MemberType NoteProperty -Name SPVersion -Value $OS.csdversion
    $OutputObj | Add-Member -MemberType NoteProperty -Name SerialNumber -Value $systemBios
    $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name UserName -Value $username.Name
    $OutputObj | Add-Member -MemberType NoteProperty -Name Last-Login -Value $username.LastWriteTime
    $OutputObj | Add-Member -MemberType NoteProperty -Name C:_GBfreeSpace -Value $driveSpace.GBfreespace
    $OutputObj | Add-Member -MemberType NoteProperty -Name Total_Physical_Memory -Value $totalMemory
    $OutputObj | Add-Member -MemberType NoteProperty -Name Last_Reboot -Value $lastboot
    $OutputObj | Export-Csv $exportLocation -Append
 write-host "Completed" $Computer
   }
}

 write-host -foregroundcolor cyan "Script is complete, the results are here: $exportLocation"
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633468
I was able to replicate your problem exactly. Let me run some debugs on this and I'll get back to you.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39633481
Thanks so much!
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633599
I'm close but not done yet. Change the line 81 to $OutputObj | Export-CSV -NoType -Path $exportLocation

It'll get the info printed in the csv, but it's only the last computer. the append switch is not working. Still working on that.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633603
Ah, what version of powershell are you running?

-Append parameter has been added to export-csv, but it does not exist in 1.0 and 2.0
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633637
alternatively, if you're ok with it, you could use
$OutputObj | Out-File -Append $exportLocation
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39633701
Ok, easy route. Upgrade your powershell to v3.0 and the script will work.

Or you can make a custom command as per http://dmitrysotnikov.wordpress.com/2010/01/19/export-csv-append/ to include the append. BUYER BEWARE! :)
0
 
LVL 3

Author Comment

by:roycbene
ID: 39633887
Lol@buyer beware. I think I'll upgrade to 3.0. I'm pretty sure that's my problem! I'll try that and let you know. Again, thanks SOOOO much!
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39634497
remember to empty out your LivePCs list every time you run this
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39638828
How did it go?
0
 
LVL 3

Author Comment

by:roycbene
ID: 39638961
I was just about to post when you rang....

The script is generating now. However, and another weird thing, it's only populating one or two users. For the rest, I'm getting the following errors: (more of my ramblings at the end of the errors)

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:4 char:16
+    $Sysbuild = get-wmiobject Win32_WmiSetting -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:5 char:10
+    $OS = gwmi Win32_OperatingSystem -Computername $Computer
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:6 char:16
+    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName
$Co ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:7 char:18
+    $driveSpace = gwmi win32_volume -computername $Computer -Filter
'drivetype =  ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:10 char:11
+    $cpu = Get-WmiObject Win32_Processor  -computername $computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At line:13 char:4
+    $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:2 char:11
+    $Bios =get-wmiobject win32_bios -Computername $Computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:3 char:16
+    $Hardware = get-wmiobject Win32_computerSystem -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:4 char:16
+    $Sysbuild = get-wmiobject Win32_WmiSetting -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:5 char:10
+    $OS = gwmi Win32_OperatingSystem -Computername $Computer
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:6 char:16
+    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName
$Co ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:7 char:18
+    $driveSpace = gwmi win32_volume -computername $Computer -Filter
'drivetype =  ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:10 char:11
+    $cpu = Get-WmiObject Win32_Processor  -computername $computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At line:13 char:4
+    $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:2 char:11
+    $Bios =get-wmiobject win32_bios -Computername $Computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:3 char:16
+    $Hardware = get-wmiobject Win32_computerSystem -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:4 char:16
+    $Sysbuild = get-wmiobject Win32_WmiSetting -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:5 char:10
+    $OS = gwmi Win32_OperatingSystem -Computername $Computer
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:6 char:16
+    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName
$Co ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:7 char:18
+    $driveSpace = gwmi win32_volume -computername $Computer -Filter
'drivetype =  ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:10 char:11
+    $cpu = Get-WmiObject Win32_Processor  -computername $computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At line:13 char:4
+    $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:2 char:11
+    $Bios =get-wmiobject win32_bios -Computername $Computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:3 char:16
+    $Hardware = get-wmiobject Win32_computerSystem -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

get-wmiobject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:4 char:16
+    $Sysbuild = get-wmiobject Win32_WmiSetting -Computername $Computer
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:5 char:10
+    $OS = gwmi Win32_OperatingSystem -Computername $Computer
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:6 char:16
+    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName
$Co ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:7 char:18
+    $driveSpace = gwmi win32_volume -computername $Computer -Filter
'drivetype =  ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT:
0x800706BA)
At line:10 char:11
+    $cpu = Get-WmiObject Win32_Processor  -computername $computer
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMExcept
   ion
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands
   .GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At line:13 char:4
+    $lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

- So I understand the RPC Server unavailable. But I do not understand the null-valued expression errors. Why would it work on some and not others? Also, why would it not just get what it could instead of skipping the computer altogether? You solved my initial problem, which I will give you full credit for, so if this is something I need to pursue in another question, I'm happy to - just let me know :) Again, thank you SO very much for all you've done.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39639123
I don't know why that was happening. I checked elsewhere and found that if you have space characters at the end of each line the input file, it could occur. Can you check and let me know?
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39639130
Also, check if the Remote Procedure Call (RPC) service is running on the computers. If it is, then it's a firewall issue between your workstation and the server. You can test it by temporary disabling the firewall and retrying the command.
0
 
LVL 20

Accepted Solution

by:
netcmh earned 500 total points
ID: 39639138
It continues because of the SilentlyContinue parameter. If you'd like it to stop, try the Inquire parameter.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39639251
I'll check and let you know. Give me just a bit. Again, thanks a ton!!
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39750833
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39753083
The asker has had approcimately 50 days to respond.  I doubt a couple more will make any difference.

mlmcc
0
 
LVL 3

Author Comment

by:roycbene
ID: 39753098
Well 'the asker' has responded. Thanks.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 39753617
LOL! Thanks roycbene. Hope you got it to work the way you wanted it. Good luck! Oh, and thanks for the grade.
0
 
LVL 3

Author Comment

by:roycbene
ID: 39753624
Thank you!!! It took some tweaking, but I finally got it. You're a genius and thanks again!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Problem Statement In an SAP BI BO Integration project when a BO universe is built on a BEx query, there can be an issue of unit & formatted value objects not getting generated in a BO universe for some key figures. This results in an issue whereb…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now