2 CSV files - combine into one CSV

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
juneb1022
Posts: 34
Last visit: Fri Sep 30, 2016 8:08 am

Re: 2 CSV files - combine into one CSV

Post by juneb1022 »

Couple quesions, runing get-qadcomputer to get the description and managed by throws an error - "get-qadcomputer" is not recognized as a cmd. Also, adding the windows license status works for the 2008 servers, but the 2003 servers uses a different -class, how can i tell it to differentiate between both operating systems?


$InventoryCSVb = "D:\Powershell\Inventory\code_testing_inventory\code_testing_inventoryb.csv"
$RemoteServerSessions = "D:\Powershell\Inventory\code_testing_inventory\RemoteSrvSessions.txt"

$Block = {

$OperatingSystem = gwmi win32_operatingsystem
$ComputerSystem = gwmi win32_computersystem
$TimeZone = gwmi Win32_TimeZone
$NIC = gwmi win32_NetworkAdapterConfiguration | where {$_.IPEnabled -eq "True"} | select IPAddress
$License = gwmi SoftwareLicensingProduct | Where-Object {$_.productkeyid -ne $null} | select LicenseStatus
$ManagedBy = Get-QADComputer -searchroot 'site' | select ManagedBy
#$License = gwmi Win32_WindowsProductActivation
$Description =


$Properties=@{
Name = $OperatingSystem.CSName
OperatingSystem = $OperatingSystem.Caption
ServicePack= $OperatingSystem.CSDVersion
PhysicalMemory = [math]::round($ComputerSystem.TotalPhysicalMemory/1GB)
NumberOfProcessors = $ComputerSystem.NumberOfProcessors
LastBootTIme = $OperatingSystem.ConvertToDateTime($OperatingSystem.LastBootupTime)
IPAddress = $NIC.IPAddress
TimeZone = $TimeZone.Caption
LicenseStatus = $License.LicenseStatus
ManagedBy = $ManagedBy.ManagedBy
Description

}

New-Object PsObject -Property $Properties

}


$sessions = Get-QADComputer -searchroot 'site' | `
Where-Object { $_.description -notlike "ClusterResource*" -and $_.description -notlike "Disaster*" -and $_.accountisdisabled -eq $False -and $_.description -notlike "*Decom?" } | `
ForEach-Object { new-pssession -ComputerName $_.Name
}


Invoke-Command -ScriptBlock $block -Session $sessions | Select 'Name','OperatingSystem', 'ServicePack','PhysicalMemory','NumberOfProcessors','LastBootTime','TimeZone','IPAddress','LicenseStatus','ManagedBy','Description' | Export-Csv $InventoryCSVb -NoTypeInformation



$sessions | Remove-PSSession
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: 2 CSV files - combine into one CSV

Post by jvierra »

THiss started as a simple question about combining CSV files. You are now asking for extensive consulting services.

I am sorry but a forum is not an appropriate place to get free consulting. If this is a critical project I recommend that you hire a consultant to help you work through these things.
User avatar
juneb1022
Posts: 34
Last visit: Fri Sep 30, 2016 8:08 am

Re: 2 CSV files - combine into one CSV

Post by juneb1022 »

Thanks, Ive poked around the forums and see you contribute quite a lot here, with the same cause of the questions. Im sure your work is commended on this site.
This topic is 10 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked