Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
AD query for Serial Numbers
Last Post 31 Dec 2009 12:42 AM by
Shay Levy
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Oldbutdeadly
New Member
Posts:1
30 Dec 2009 12:13 PM
Good afternoon everyone!
I was wondering if you could help me with this. Here is my code (Using Quest) that pulls computer names from a csv file and queries AD for DN, LASTLOGONTIMESTAMP and IP information. (It works well)
$ip = @{name="IP";expression={[System.Net.Dns]::GetHostByName($_.name).AddressList[0].IPAddressToString}}
Import-Csv C:\scripts\AVlist.csv | Get-QADComputer -Identity {$_.Name} -IncludedProperties lastLogonTimeStamp | Select-Object DisplayName,DN,LastLogonTimeStamp,$ip | export-csv c:\scripts\kevin.csv –noType
Here is an entry that gets serial numbers (If computer is on) in powershell….
Get-WMIObject -Class "Win32_BIOS" -Computer WSNR11840 | select SerialNumber
How would you integrate that command into the script? I want to do something like:
$SN = Get-WMIObject -Class "Win32_BIOS" -Computer WSNR11840 | select SerialNumber
But I want to change that computer name to ($_.name) so I can pull it from that CSV file. Can I do that? I then would add $SN to my export just like $ip was done…exporting it to a csv file…
Kevin
Shay Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
31 Dec 2009 12:42 AM
Just like you did with $ip ;-)
$ip = @{name="IP";expression={[System.Net.Dns]::GetHostByName($_.name).AddressList[0].IPAddressToString}}
$sn= @{name="SerialNumber";expression={(Get-WMIObject -Class Win32_BIOS -Computer $_.name).SerialNumber}}
Import-Csv C:\scripts\AVlist.csv | Get-QADComputer -Identity {$_.Name} -IncludedProperties lastLogonTimeStamp | Select-Object DisplayName,DN,LastLogonTimeStamp,$ip,$sn | export-csv c:\scripts\kevin.csv –noType
Shay Levy
Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter:
@ShayLevy
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2