Page 3 of 3

Re: 2 CSV files - combine into one CSV

Posted: Thu Oct 03, 2013 5:33 pm
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

Re: 2 CSV files - combine into one CSV

Posted: Thu Oct 03, 2013 8:28 pm
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.

Re: 2 CSV files - combine into one CSV

Posted: Fri Oct 04, 2013 7:22 am
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.