hello guys ,<\/p>\n
im trying to export the computers serialnumbers + screens serialnumbers , for that i have this powershell script<\/p>\n
$ComputerName = 'computers'\n$bios = Get-WmiObject win32_bios -ComputerName $ComputerName | select pscomputername,serialnumber,name,serial\n$mon = Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\tNew-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Name = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n }\n} \n\nWrite-Output $bios,$mon\n<\/code><\/pre>\n
Advertisement
in the output in the column \" name \" im getting both names of pc and screen<\/p>\n
PSComputerName serialnumber name serial \n-------------- ------------ ---- ------ \ncomputer XXXXXXXXXX Default System BIOS \n HP P201 XXXXXXXXX\n<\/code><\/pre>\n… i would like to get only the name of the screen … how can i do that ?<\/p>\n
thank you<\/p>","upvoteCount":6,"answerCount":11,"datePublished":"2019-07-04T08:09:20.000Z","author":{"@type":"Person","name":"oumolayna","url":"https://community.spiceworks.com/u/oumolayna"},"acceptedAnswer":{"@type":"Answer","text":"
Think they meant like this:<\/p>\n
$results = @()\n\n$bios = Get-WmiObject win32_bios -ComputerName $ComputerName | select pscomputername,serialnumber\nGet-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\t$mon = New-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n monname = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n }\n $results += [pscustomobject]@{\n PCName = $bios.PSComputerName\n PCSerialNo = $bios.serialnumber\n MonName = $mon.monname\n MonSerialNo = $mon.Serial\n MonManufacturer = $mon.Manufacturer\n }\n}\n\n$results | Export-Csv -Path \"C:\\Blah.csv\" -NoTypeInformation\n<\/code><\/pre>","upvoteCount":3,"datePublished":"2019-07-04T10:00:04.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/5","author":{"@type":"Person","name":"francishagyard2","url":"https://community.spiceworks.com/u/francishagyard2"}},"suggestedAnswer":[{"@type":"Answer","text":"hello guys ,<\/p>\n
im trying to export the computers serialnumbers + screens serialnumbers , for that i have this powershell script<\/p>\n
$ComputerName = 'computers'\n$bios = Get-WmiObject win32_bios -ComputerName $ComputerName | select pscomputername,serialnumber,name,serial\n$mon = Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\tNew-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Name = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n }\n} \n\nWrite-Output $bios,$mon\n<\/code><\/pre>\nin the output in the column \" name \" im getting both names of pc and screen<\/p>\n
PSComputerName serialnumber name serial \n-------------- ------------ ---- ------ \ncomputer XXXXXXXXXX Default System BIOS \n HP P201 XXXXXXXXX\n<\/code><\/pre>\n… i would like to get only the name of the screen … how can i do that ?<\/p>\n
thank you<\/p>","upvoteCount":6,"datePublished":"2019-07-04T08:09:21.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/1","author":{"@type":"Person","name":"oumolayna","url":"https://community.spiceworks.com/u/oumolayna"}},{"@type":"Answer","text":"
try:<\/p>\n
$bios = Get-WmiObject win32_bios -ComputerName $ComputerName | select pscomputername,serialnumber,monname,serial\n$mon = Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\tNew-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n monname = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n }\n} \n\nWrite-Output $bios,$mon\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2019-07-04T08:24:21.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/2","author":{"@type":"Person","name":"jb04","url":"https://community.spiceworks.com/u/jb04"}},{"@type":"Answer","text":"it worked … but still im getting the screen name on another row … i want them on the same row if possible because i want to export them to a csv<\/p>\n
can it be done ?<\/p>","upvoteCount":0,"datePublished":"2019-07-04T08:34:54.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/3","author":{"@type":"Person","name":"oumolayna","url":"https://community.spiceworks.com/u/oumolayna"}},{"@type":"Answer","text":"
Ah I see how you mean it, look at this:<\/p>\n
$ComputerName = 'computername'\n$bios = Get-WmiObject win32_bios -ComputerName $ComputerName | select pscomputername,serialnumber,name,monname,serial\n$mon = Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\tNew-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n monname = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n }\n} \n\nWrite-Output $bios,$mon|ft\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2019-07-04T09:43:37.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/4","author":{"@type":"Person","name":"jb04","url":"https://community.spiceworks.com/u/jb04"}},{"@type":"Answer","text":"Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName | foreach {\n\t$mon = New-Object -TypeName psobject -Property @{\n Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n monname = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join \"\"\n<\/code><\/pre>\ncan someone explain this to me ? how is this working ?<\/p>\n
because when i run<\/p>\n
Get-WmiObject -Namespace root\\wmi -ClassName wmimonitorid -ComputerName $ComputerName\n<\/code><\/pre>\ni get some weird numbers like<\/p>\n
ManufacturerName : {12, 34, 45, 0...}\nProductCodeID : {59, 53, 56, 49...}\nSerialNumberID : {55, 66, 77, 88...}\nUserFriendlyName : {33, 22, 11, 99...}\nUserFriendlyNameLength : 13\n<\/code><\/pre>\nthank you<\/p>","upvoteCount":0,"datePublished":"2019-07-09T04:38:55.000Z","url":"https://community.spiceworks.com/t/powershell-select/719463/6","author":{"@type":"Person","name":"oumolayna","url":"https://community.spiceworks.com/u/oumolayna"}},{"@type":"Answer","text":"
Hi,<\/p>\n