I'm an idjit. The problem is that the machines in question don't have DCOM enabled. No DCOM, no remote WMI.
DAMIEN SOLODOW Systems Engineer 317.447.6033 (office) 317.447.6014 (fax) HARRISON COLLEGE From: Michael B. Smith [mailto:mich...@smithcons.com] Sent: Monday, October 17, 2011 5:07 PM To: NT System Admin Issues Subject: RE: Help with PS script? Is it consistently the same computers? If so, you need to look at the permissions on the objects... Sent from my HTC Tilt(tm) 2, a Windows(r) phone from AT&T ________________________________ From: Damien Solodow <damien.solo...@harrison.edu> Sent: Monday, October 17, 2011 4:36 PM To: NT System Admin Issues <ntsysadmin@lyris.sunbelt-software.com> Subject: RE: Help with PS script? Ok, one more weird thing. I've got it getting a list of computers via get-adcomputer to run against, and most of the computers it's fine one. But a number of them return an access denied during the foreach-object. However, if I modify the filter to run against some of the machines reporting access denied, they return fine. Here is the current script: Import-Module ActiveDirectory $adminaccount = Get-Credential Get-ADComputer -Filter {OperatingSystem -Like "Windows *Server*"} -SearchBase "DC=domain,DC=local" | ForEach-Object -process { Get-WmiObject -class Win32_ComputerSystem -ComputerName $_.Name -Credential $adminAccount | Select-Object ` @{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 $_.Name -Credential $adminAccount | Select-Object -expand Caption).ToString()}}} | Export-Csv -Path "c:\users\public\documents\ServerInfo.csv" -NoTypeInformation DAMIEN SOLODOW Systems Engineer 317.447.6033 (office) 317.447.6014 (fax) HARRISON COLLEGE From: Damien Solodow [mailto:damien.solo...@harrison.edu] Sent: Monday, October 17, 2011 3:53 PM To: NT System Admin Issues Subject: RE: Help with PS script? Doh! Thanks much. I didn't know about the .tostring() trick. DAMIEN SOLODOW Systems Engineer 317.447.6033 (office) 317.447.6014 (fax) HARRISON COLLEGE From: Michael B. Smith [mailto:mich...@smithcons.com]<mailto:[mailto:mich...@smithcons.com]> Sent: Monday, October 17, 2011 3:49 PM To: NT System Admin Issues Subject: RE: Help with PS script? Change the format-table to select-object. Regards, Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com From: Damien Solodow [mailto:damien.solo...@harrison.edu]<mailto:[mailto:damien.solo...@harrison.edu]> 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:mich...@smithcons.com]<mailto:[mailto:mich...@smithcons.com]> 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:damien.solo...@harrison.edu]<mailto:[mailto:damien.solo...@harrison.edu]> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe ntsysadmin