2 CSV files - combine into one CSV

Ask your Windows 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.
User avatar
juneb1022
Posts: 34
Joined: Mon Jun 10, 2013 10:14 am

Re: 2 CSV files - combine into one CSV

Post by juneb1022 » Thu Oct 03, 2013 5:33 pm

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

User avatar
jvierra
Posts: 13792
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: 2 CSV files - combine into one CSV

Post by jvierra » Thu Oct 03, 2013 8:28 pm

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
Joined: Mon Jun 10, 2013 10:14 am

Re: 2 CSV files - combine into one CSV

Post by juneb1022 » Fri Oct 04, 2013 7:22 am

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.

Locked