Computers inventory

Hello,

I’m new to this forum (actually just registered) and I need some help.

I’m new to PowerShell but I was able to get partial information of what I want and putting them all together does not seem possible for my level of knowledge.

Basically, I would like to generate a csv file with the following information per computer on the network (or Get-Content from a text file).

ComputerName, CurrentlyLoggedOnUser, OS (Win 7/10), PhysicalDiskSize (GB), TotalPhysicalMemory (GB), CPU Type (i5/i7), Dell Service Tag as well, since all of our computers/laptops are Dell.

Could someone please help me with that?

 

Thank you in advance, :slight_smile:

 

You are at the right place !

These were all time requirements in the industry and already been solved. Below link will help you to get started.

https://gallery.technet.microsoft.com/Windows-System-Inventory-9b27593e

There are many such scripts in the public network :slight_smile:

Thanks @kvprasoon. This is very sophisticated.

@85xlt75 - Precise to your requirement, you can use the script below…

https://gist.github.com/b20e7103ead3fc48137a83deea68edc8

As kvprasoon said, this is one of most common tasks and most books use this example to create tools in Powershell, so there are basic to advanced scripts that output Powershell or HTML reports.

@Kiran: Move '$Output = ’ in front of foreach ($CN in $ComputerName) to support returning multiple computers.

$Output = foreach ($CN in $ComputerName)

@Rob Simmers, Thanks for pointing it out, I have updated it in the gist. Thank you.

Hi Kiran,

I tried your script and although it did not give any error, it did not do anything else either. It just brought me back to the prompt.

Why would it not show any output?

Thank you,

[quote quote=186793]Hi Kiran,

I tried your script and although it did not give any error, it did not do anything else either. It just brought me back to the prompt.

Why would it not show any output?

Thank you,

[/quote]
It’s a function, and you need to call explicitly…

[pre]

Now call the function

Get-Inventory -ComputerName comp1,comp2…,compn

[/pre]

Thank you.

Hi kvprasoon,

I run your script and although it displayed a lot of errors, it did what it was supposed to.

For testing purposes, I selected only two workstations and it gave me all the requested information except for the currently logged on user.

Is there a way to add that? You can tell me what to add and where to add it on the script and I will do it then test again.

Thank you,

 

 

 

Hi Kiran,

Still nothing.

I tried Get-Content from a txt file, I tried Get-Content from a variable and I tried .\Get-Inventory -ComputerName WKS1, SRV1.

It brought me back to the prompt with no errors and no output.

Thank you,