Odd issue with get-computerinfo via PSExec

hi there!

My last post wasn’t very well received, so I’ve learned from my mistakes and have a better, more thoughtout post this time.

I’m trying to gather various system info on our network computers with PSExec and get-computerinfo, however, when I run this script, it doesn’t print anything in the properties I’ve searched for, but when I search for all properties, it prints them.

PSExec \[ComputerName]-s -n 5 powershell get-computerinfo -property * | Select cscaption, csusername, csprocessors, powerplatformrole

Any help would be greatly appreciated!

No. You don’t. :smirk: While your code is way shorter this time it is still unformatted.

What you’re trying to do is a very common task and has been asked a thousand times already and has been answered a thousand times already. Please use your prefered interent search engine and look for examples for tasks like this. There’s no need to re-invent the wheel again and again. :man_shrugging:t3:

Why don’t you use PowerShell remoting?

Typically we’d use something like this:

$ComputerName = 'RemoteComputer'

if (Test-Connection $ComputerName -Quiet -Count 1) {
    $CimSession = New-CimSession -CN $ComputerName
    $Computer   = Get-CimInstance -Class CIM_ComputerSystem  -CimSession $CimSession 
    $BIOS       = Get-CimInstance -Class CIM_BIOSElement     -CimSession $CimSession 
    $OS         = Get-CimInstance -Class CIM_OperatingSystem -CimSession $CimSession 
    Remove-CimSession $CimSession
    [PSCustomObject]@{
        ComputerName   = $BIOS.PSComputerName;
        Model          = $Computer.Model;
        BIOSName       = $BIOS.Name;
        SMBIOSVersion  = $BIOS.SMBIOSBIOSVersion;
        BIOSVersion    = $BIOS.BIOSVersion;
        ReleaseDate    = $BIOS.ReleaseDate;
        SerialNumber   = $BIOS.SerialNumber;
        OSCaption      = $OS.Caption;
        OSVersion      = $OS.Version;
        InstallDate    = $OS.InstallDate;
        LastBootUpTime = $OS.LastBootUpTime;
        PhysicalRAM    = [math]::round((($Computer.TotalPhysicalMemory) / 1GB), 2);
    }
}
else {
    "`tThe computer '$($ComputerName)' is unreachable`n"
}

I was not aware that powershell remoting was capable of doing this task, and it is not a company standard where I work.

As far as searching for what I’m doing, either I don’t understand the things that I’ve found for doing this task, or I’m not finding the answers I’m looking for. So far this is the furthest I have gotten in this script, and I have tried a lot of different ways of achieving it.

Also I forgot about the formatting desired for this site.

Make it one.

Well we cannot understand it for you. :man_shrugging:t3:

You might improve your search skills. Mostly it is about using the proper key words. But you may keep in mind that for the vast majority of the cases or tasks you’re not the very first one. The chances are very high that you find something similar to your task you can tweak for your own needs.

You may do a big step back a start with learning the very fundamentals of PowerShell first. This will save you from a lot of wasted time and frustrations. And it wil lenable you to understand the help you get in forums like this.

You could still do it. Just go back, edit your question and fix the formatting. :smirk:

I don’t seem to have the code format button from the tutorial link you sent me.

Hmmm … that’s weird.

Would it be polsibble to load multiple values in get-computerinfo -properties [Values] or is it limited to only one value?

I found that if I take out the | Select [Values] the command runs, but returns blank lines if it’s left in.

Again … take a step back and learn the basics. That will contain a lesson how to read the help for the cmdlets you’re about to use.

Read the help completely including the examples and try it.

According to the help documentation, my pipe should work. get-computerinfo accepts piping.

If you have a specific issue with a particular piece of code you wrote please share this code here as complete as needed to show your issue and describe what’s not working as expected.

Alright, here’s the code that I’m running:

PSExec \ComputerName -s powershell get-computerinfo -property * | Select PowerPlatformRole

and here’s the result in the Console:

Here’s the other end of the Console output.

Please do not post images of code as this is not helpful at all. Instead post the plain text formatted as code. You can format code even without the button in the edit bar when you put 3 consecutive backticks on an empty line then your code starting on the next line and then again 3 consecutive backticks on an empty line after your code.

And again … you should use PowerShell remoting:

Invoke-Command -ComputerName 'remoteComputer' -ScriptBlock {
    Get-ComputerInfo
}

Or … if you really want to get only the one property …

Invoke-Command -ComputerName 'remoteComputer' -ScriptBlock {
    Get-ComputerInfo -Property PowerPlatformRole
}

Powershell remoting isn’t an option for me, I’ll have to do this another way.

I cannot enable powershell remoting because I do not have the authority in my company to make that change or descision.

I included the pictures because my output is quite litterally, nothing, and it’s difficult to describe nothing without a photo.

And for proper formatting…

PSExec \\[RemotePCName] -s powershell get-computerinfo -property * | Select PowerPlatformRole

I am only grabbing one property because I was testing this line, I’m wanting to grab multiple properties.

Why don’t you at least give it a try with one computer? It will not hurt you.

If you’ve got the task of querying remote Windows computers PowerShell remoting is the way to go. You don’t have to decide it yourself but you should at least try to convince the according department to support a well supported industry wide state of the art technique for gathering information from remote computers in a Windows domain network. :man_shrugging:t3: … just my 2 cts.

We trust you when you tell us that you don’t get any output. Images of code or console output just don’t make sence.

:man_shrugging:t3:

I already posted the proper command to get only this one property. :man_shrugging:t3:

I cannot help you with psexec because I do not have any experience with it. And it is not PowerShell.

The slashes aren’t working for me either. I’ve got 3 backslashes in my draft of that post, but only 1 and 2 in the post.

Thank you for your time with this.

Slashes? Backticks!!! If you don’t know what this is - google it!

I’m from America, where I live we call them backslashes or forward slashes.

Please google it. We call backslashes backslashes as well. But I am talking about backticks!!!

Formatting your code to make it easier to read is actually really simple. You can manually format using the back tick key repeated 3 time. Then next line put your code you want us to look at, then very last line is 3 more back ticks.

`   <<< repeate that key a total of 3 times in a row to get started.  
TonyBoy82:
As far as searching for what I’m doing, either I don’t understand the things that 
I’ve found for doing this task, or I’m not finding the answers I’m looking for. 

One of the best free sources to get you started better understanding PowerShell, other than MS documentation which can assume you know things you do not sometimes, is located here Windows PowerShell 4.0: TFM (The F****** Manual)

1 Like