Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Powershell, AD, and CSV file

  • Please log in to reply
No replies to this topic

#1 leoliger


  • Members
  • 79 posts
  • Gender:Not Telling
  • Local time:04:21 AM

Posted 28 March 2014 - 01:51 PM

I want to make a script that will allow me to automate searhing for computer names in AD from a CSV Excel sheet file. On the CSV file I have the Computer Name on column A, columun B had System (or Modified Date), and the last is Pinging the computer to see if it is able to communicate. i wanted that information written back into the CSV for reporting. I am pretty green on Powershell, but I understand that if you can effectivly run a script using Powershell it woud make my job easier, but like I said I am a novice in programming in general and can run simple commands, but nothing like the length that I am trying to understand to write.


Some of the code that I am going to show was takening from another site, but allowing my to modify it to meet what I am trying to do. Here is what I have so far:


$xl=New-Object -ComObject "Excel.Application"
$wb=$xl.Workbooks.Open($file) -- This will hold the exacted file name that I have on my desktop.


do {
  if ($data) {
    Write-Verbose "Querying $data"
        $data=Get-Adcomputer -Filter*| Select-Object Name, Modified
        $ping=Test-Connection -ComputerName $data -Quiet
        if ($Ping) {
        $OS=(Get-WmiObject -Class Win32_OperatingSystem -Property Caption -computer $data).Caption
      else {    
        New-Object -TypeName PSObject -Property @{
    While ($data)


I am still trying to understand Powrshell, but I need some time t understand the Syntax as programming is not my thing, but I understand how powershell can be.

BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users