Change the format-table to select-object. Regards,
Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com From: Damien Solodow [mailto:[email protected]] Sent: Monday, October 17, 2011 3:39 PM To: NT System Admin Issues Subject: RE: Help with PS script? Hmmm... I added | Export-CSV -path file.csv to it and it ran successfully. However, the resulting CSV looks like this: ClassId2e4f51ef21dd47e99d3c952918aff9cd pageHeaderEntry pageFooterEntry autosizeInfo shapeInfo groupingEntry 033ecb2bc07a4d43b5ef94ed5a35d280 Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo 9e210fe47d09416682b841769c78b8a3 27c87ef9bbda4f709f6b4002fa4af63c 4ec4f0187cb04f4cb6973460dfe252df cf522b78d86c486691226b40aa69e95c DAMIEN SOLODOW Systems Engineer 317.447.6033 (office) 317.447.6014 (fax) HARRISON COLLEGE From: Michael B. Smith [mailto:[email protected]]<mailto:[mailto:[email protected]]> Sent: Monday, October 17, 2011 3:32 PM To: NT System Admin Issues Subject: RE: Help with PS script? Don't overthink it. $adminAccount = Get-Credential $ServerName = "string" Get-WmiObject -class Win32_ComputerSystem -ComputerName $ServerName -Credential $adminAccount | Format-Table ` @{l='ComputerName';e={$_.__Server.ToString()}},` @{l='Manufacturer';e={$_.Manufacturer.ToString()}},` @{l='Model';e={$_.Model.ToString()}},` @{l='Operating System';e={(Get-WmiObject -class Win32_OperatingSystem -ComputerName $ServerName -Credential $adminAccount | Select-Object -expand Caption).ToString()}} -AutoSize You should be able to pipe that to export-csv (perhaps minus the autosize - I didn't test it). Regards, Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com From: Damien Solodow [mailto:[email protected]]<mailto:[mailto:[email protected]]> Sent: Monday, October 17, 2011 1:44 PM To: NT System Admin Issues Subject: Help with PS script? I'm trying to make a Powershell script to get a list of computer objects from AD, and query some AD properties from them and export to a CSV. The part I have working does the queries and exports the data I want to a table. The export-csv is giving me grief, and I think it's because I need to convert the data to strings to export them out. I think after the get-adcomputer I need to do a foreach-object to run the script block for each, but I'm having a brain fart. Here's the part I have for the WMI info I need: $adminAccount = Get-Credential $ServerName = "string" Get-WmiObject -class Win32_ComputerSystem -ComputerName $ServerName -Credential $adminAccount | Format-Table ` @{l='ComputerName';e={$_.__Server}},` @{l='Manufacturer';e={$_.Manufacturer}},` @{l='Model';e={$_.Model}},` @{l='Operating System';e={Get-WmiObject -class Win32_OperatingSystem -ComputerName $ServerName -Credential $adminAccount | Select-Object -expand Caption}} -AutoSize DAMIEN SOLODOW Systems Engineer 317.447.6033 (office) 317.447.6014 (fax) HARRISON COLLEGE 500 North Meridian St Suite 500 Indianapolis, IN 46204-1213 www.harrison.edu<http://www.harrison.edu/> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
