How to make the result showing one time and make the result to csv file?

My script having problem of showing out all the AD computer name result  from Active Directory once when running it and storing the result to csv file. I am a newbie in AD and powershell.
This is the code:
$strADPathFile = "D:\Powershell for AD\ADPathList.txt"
$strErrLogFile = "D:\powershell for AD\errorADComputer.log"
$arrADPath = Get-Content -Path $strADPathFile
foreach ($strADPath in $arrADPath)
try
$objSearch = New-Object DirectoryServices.DirectorySearcher
$objSearch.Filter = '(objectCategory=computer)'
$objSearch.SearchRoot = $strADPath
$objSearch.SearchScope = "Subtree"
$objSearch.PageSize = 1000
$objResults = $objSearch.Findall()
write-host "Retrieving AD computer information in the domain $strDomain"
write-host "Number of AD Computer Name result: "$objResults.Count
foreach($objResult in $objResults){
$objComputer = $objResult.GetDirectoryEntry()
write-host $objComputer.dNSHostName
try
# InsertSQLTable $objComputer
catch
write-host $error[0]
$strError = $objComputer.dNSHostName + " " + $dateNow + $error[0]
Add-Content $strErrLogFile $strError
catch
write-host $error[0]
Export-Csv D:\PowerShellforAD\test2.csv
This is the error that I had get is that it will get the result for 2nd time again.
By the way, what is InputObject about? I had research some of it and still did not quite get it. Can anyone explain? Thanks 

Hi,
in the final line you call Export-Csv. which is a great command at exporting information. However, for it to work it needs a path to export to (D:\PowerShellforAD\test2.csv in your case) and Information (InputObject) to export.
You do not give that command any Information, so it throws an error.
Cheers,
Fred
There's no place like 127.0.0.1

Similar Messages

  • How to load the data from .csv file to oracle table???

    Hi,
    I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
    Thanks in advance

    981145 wrote:
    Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
    the command is
    sqlldrType it and see if you have it installed.
    Have a look also at the FAQ link posted by Marwin.
    There are plenty of examples also on the web.
    Regards.
    Al

  • How to read the name of .csv file from a particular folder using Oracle.

    Gurus,
    I have a folder called 'data_dir' in Oracle Server and it contains 10 different .csv files and the name of the each file is being suffixed by date and time(24 hrs format).
    First i need to read all the file names then i have to process those files by UTL_FILE to load the data into a relational table.
    Is there any mechanism is available in Oracle to read the file names?
    (In this case all the 10 different csv file names)
    If so, then please help me accomplish this.
    Thanks in advance.
    Regards,
    Venugopal.K

    Is there any mechanism is available in Oracle to read the file names?Sounds to me like you need to use External Tables (*not* utl_file).
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/et_concepts.htm

  • I created a form with Single Choice fields, 4 days with times listed. But, I want the user to only be able to choose one time, and the time chosen to be unavailable for other users. How do I do this?

    I created a form with Single Choice fields, 4 days with times listed. But, I want the user to only be able to choose one time, and the time chosen to be unavailable for other users. How do I do this? I have 4 blocks of Single Choice fields in order for the summary page to give me each day in the final report. But, I need the user to be able to make a selection of any day and time and that apointment to no longer be available to future users when they log in. Plus, when the user clicks on the time, they are unable to change their mind and choose another time. Here's the link if you want to see what I'm talking about: 2015-2016 Workload Apportionment Review

    I'm afraid not.    It's not rocket science but you need to do some coding. 
    You'll need to find a script (php) and save it to your local site folder.  Then reference the script in your form's action attribute like so.
         <form action="path/form-to-email-script.php" >
    The input fields in your HTML form need to exactly match the script variables. 
    I'm  assuming you're hosted on a Linux server which uses PHP code.  Linux servers are also case sensitive, so upper case names are not the same as lower case names.  It's usually best to use all lower case names in your form and script to avoid confusion.
    Related Links:
    Formm@ailer PHP from DB Masters
    http://dbmasters.net/index.php?id=4
    Tectite
    http://www.tectite.com/formmailpage.php
    If this is all a bit beyond your skill set, look at:
    Wufoo.com (on-line form service)
    http://wufoo.com/
    Nancy O.

  • How do you get table column names to show one time per page

    I have a report where I want the column names to show one time per page.
    I have the table with the column names set below the header and above the
    'for-each Row'.
    When I view the report in PDF format the colunm names show only one time on the first page and on the other pages the column names do not show at all. If I view the report in RTF, the same thing happens, shows column names on the first page, but not on the other pages after that.
    I highlighted the table and went to table properties, clicked on ROW tab and then checked (Repeat as header row at the top of each page) and it still does not work for PDF or RTF format. I have looked at other forums with this issue and it doesn't work for me in PDF format.
    Could someone tell me what I am doing wrong.....
    I appreciate anyone that can help me.
    Thank you,
    Susie

    I figured out what I was doing wrong.
    I was creating a seperate table for the column names and not using the table where the column names where created originally. I deleted the column names from the original table and created a seperate table above that table with the column names only.
    So I went back to the original table and highlighted the row with the column names and went to table properties/ROW tab/ and clicked (Repeat as header row at the top of each page) and now it works perfectly in PDF format where the column names show one time for each page. Deleted the other table where I had the column names only.
    thanks
    Susie

  • How can I clean up queue one-time on Sun Java system messaging 6.3

    Hi,
    <address>Our Email server have a problem, When I run _./imsimta qm directory tcp_local_, There are about 5 Millions of messages in the queue.</address>
    Now our Email server send messages very slowly, how can I clean up queue one-time?
    the command _./imsimta qclean_ is very slowly.
    What can I do to prevent this problem?
    our Email server version is :
    Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)
    libimta.so 6.3-6.03 (built 17:12:37, Mar 14 2008; 32bit)
    SunOS email-1 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V890
    Thank you !

    If you have more than 100,000 messages in the queue, then look at the MAX_MESSAGES parameter in [the job_controller.cnf file|http://wikis.sun.com/display/CommSuite/Job+Controller+Configuration+File]. If the parameter is not specified, it defaults to 100000. If you have more than that number of messages in the channel queues, it will take a long time for new/legitimate messages to be sent because job_controller is only considering the first 100,000 messages in the queue.
    If you get into the "imsimta qm" command do do "sum -database", it will show a summary of what job_controller has in its internal cache and therefore what job_controller is working on. If you compare that to "sum -directory" you will probably see a difference.
    If these are all legitimate messages, you need to increase MAX_MESSAGES, cnbuild, and restart job_controller.
    If they are not, then preventing this in the future will require determining how they got into your queue and correcting that.
    As for removing them, the "imsimta qm" commands allow you to select messages by various criteria and then you can "return" or "delete" them. But yes, that will take a long time if there are many messages because it is a single threaded process and it needs to open and examine each message. You may be able to accomplish the task more quickly with a shell script that works on individual channel queue subdirectories and then run multiple copies of that script in parallel. After you have cleaned out the queue, restart job_controller.
    Also, you might want to consider [the subdirs channel keyword|http://msg.wikidoc.info/index.php/Subdirs_and_nosubdirs_Channel_Options].

  • How can I convert multiple files at one time and not one at a time

    How can I convert multiple files at one time and not one at a time

    Hi Plissey1950,
    Sorry for the lengthy delay to a response.  Are you trying to convert multiple files to individual PDF files at the same time? (not combine them).  If so, you'll need to use Adobe Acrobat for this function. The CreatePDF service does not have the ability to convert multiple files to multiple individual PDF files.
    Thanks,
    David

  • How can i delete emails from my iphone or ipad one time and have it be deleted on all my devices?

    I have an iphone and ipad and want to be able to delete an email on one time and have it delete it all all my devices, including my MacBook Pro. I have Cloud set up.

    I think this might work. Im not sure though, but give it a try.
    Settings > iCloud
    Make sure Mail is turned on
    Delete the accounts you want to delete
    It should be gone from all devices

  • How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and Power Book

    How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and MacBookPro

    It is generally better to leave the old backups and start again.. unless there is something you particularly need.
    But if you desperately want all the old backups you have to copy the sparse bundles.. this will take very long time as it must copy via the computer..
    http://pondini.org/TM/18.html
    Take particular note of the initial comments.. ie before you read how to do it.. don't do it.

  • TS3218 My iPod Nano 6th generation fell one time and it kept working with a small crack in the screen.But after a while it just gave out and does not turn on.I try to charge it and all it does is blink the apple icon on and off.When disconnected nothing h

    My iPod Nano 6th generation fell one time and it kept working with a small crack in the screen.But after a while it just gave out and does not turn on.I try to charge it and all it does is blink the apple icon on and off.When disconnected nothing happens.

    I am having the identical trouble as described above with my month old Macbook Air. I tried everything with the ditto results. Please help anyone!
    Mine is a Macbook Air 13', 128GB, 1.86GHz with 4 GB RAM.

  • How create multiple named folders at one time? 10.10.02

    How create multiple named folders at one time? 10.10.02
    Hello all,
    I need to create 208 named folders at one time. Please advise.
    Thanks!

    You may want to ask this in the Yosemite forum. This is the Mavericks forum.

  • My iphone 4 Carrier signal is very weak just shows one bar and often shows No Service followed by searching and again one signal bar I have had a lot of drop calls, I have tested the sim card on my Samsung Ace which shows full Signal strength I am on the

    My iphone 4 Carrier signal is very weak just shows one bar and often shows No Service followed by searching and again one signal bar I have had a lot of drop calls, I have tested the sim card on my Samsung Ace which shows full Signal strength I am on the latest iphone firmware 5.1.1 with 4.12.01 baseband I have tried resetting the iphone did o full restore twice. I guess there is something wrong with the iphone hardware? Has anyone had similar issues and how they fixed it?

    Take the device to Apple or an Apple authorized service center and let them check it out.

  • HOW DO YOU" DELETE BOOKMARKS" AT ONE TIME WITHOUT DELETING ALL.

    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How do you" delete bookmarks" at one time, but not all of them. For instance highlight the ones you don't want. But with Fx that doesn't work. I love Fx and tell everyone I know about you and have for years. Please help !!!!!
    == Troubleshooting information
    ==
    How do you" delete bookmarks" at one time, but not all of them. For instance highlight the ones you don't want. But with Fx that doesn't work. I love Fx and tell everyone I know about you and have for years. Please help !!!!!
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
    == Plugins installed
    ==
    *-Shockwave Flash 10.0 r32
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.2"
    *NPRuntime Script Plug-in Library for Java(TM) Deploy
    *Google Update
    *Java(TM) Platform SE binary
    *Next Generation Java Plug-in 1.6.0_20 for Mozilla browsers
    *Npdsplay dll
    *DRM Store Netscape Plugin
    *DRM Netscape Network Object

    Please take a look at knowledge base article [[Deleting Bookmarks]] on how to delete one or more bookmarks at once.

  • Why does my apple id in app store settings show one thing and in the apps it shows a different id (ccl43) no email address)

    why does my apple id in app store settings show one thing and in the apps it shows a different id (ccl43) no email address) 
    I am unsure what to do I cannot get into my apps account in order to upgrade it.  HELP PLEASE!!!!!!

    It's the Apple ID that app was purchased with.

  • If i buy an iphone 5s sprint can i use it for CDMA? I ask that because i went out of the country one time and used it on a CDMA network but that was my iphon 5 not an i phone 5s.

    if i buy an iphone 5s sprint can i use it for CDMA? I ask that because i went out of the country one time and used it on a CDMA network but that was my iphon 5 not an i phone 5s.

    Sprint is a CDMA carrier, same as Verizon so it will work on CDMA.

Maybe you are looking for