Duplicates in the results of my scan...not sure why?

Hello,
I'm using the following bit of code to scan all computers in a file to look for the IP Address, Subnet Mask, DNS Servers, MAC Address and Gateway.
It's working, but I'm seeing in my results sometimes multiple lines of exactly the same information for some of the computers I'm scanning?  I'm asking this community if they can think of why this would occur?
Thank you.
Here is my code:
$dataColl = @()#Makes an array, or a collection to hold all the object of the same fields.
$outputresults = "C:\Apps\Powershell_Scripts\Diskspace\subnetscan.csv"
#process {
foreach ($Computer in (get-content C:\Apps\Powershell_Scripts\Diskspace\servers.txt))
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
foreach ($Network in $Networks) {
$IPAddress = $Network.IpAddress[0]
$SubnetMask = $Network.IPSubnet[0]
$DefaultGateway = $Network.DefaultIPGateway
$DNSServers = $Network.DNSServerSearchOrder
$IsDHCPEnabled = $false
If($network.DHCPEnabled) {
$IsDHCPEnabled = $true
$MACAddress = $Network.MACAddress
$OutputObj = New-Object -Type PSObject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value ($IPAddress -join ",")
#$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
$OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
#$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value $DefaultGateway
$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value ($DefaultGateway -join “,”)
#$OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled
$OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value ($DNSServers -join ",")
$OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
$dataColl += $OutputObj
$dataColl | Export-Csv -noTypeInformation -path $outputresults

Are you running PowerShell 2.0, by chance?  Your code looks like it should work fine on PowerShell 3.0 or later, but there's one little "gotcha" with foreach loops in PowerShell 2.0:
$collection = $null
foreach ($item in $collection)
Write-Host "Loop Body Executed"
In PowerShell 2.0, the loop body will execute once, which people tend not to expect.  This was treated as a bug, and in PowerShell 3.0, if the collection is null, the loop doesn't do anything.  Even with that bug taken into account, I'm not sure
how you're getting duplicate results, but you can try adding a check to make sure $Networks is not null before you enumerate over it, just to see if it helps:
$outputresults = "C:\Apps\Powershell_Scripts\Diskspace\subnetscan.csv"
get-content C:\Apps\Powershell_Scripts\Diskspace\serverstst.txt |
ForEach-Object {
$computer = $_
if (Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
if ($Networks)
foreach ($Network in $Networks) {
$IPAddress = $Network.IpAddress[0]
$SubnetMask = $Network.IPSubnet[0]
$DefaultGateway = $Network.DefaultIPGateway
$DNSServers = $Network.DNSServerSearchOrder
$IsDHCPEnabled = $false
If ($network.DHCPEnabled) {
$IsDHCPEnabled = $true
$MACAddress = $Network.MACAddress
$OutputObj = New-Object -Type PSObject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value ($IPAddress -join ",")
#$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
$OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
#$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value $DefaultGateway
$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value ($DefaultGateway -join “,”)
#$OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled
$OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value ($DNSServers -join ",")
$OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
$OutputObj
} |
Export-Csv -noTypeInformation -path $outputresults

Similar Messages

  • Making a complex button with the Tween class...not sure why this isn't working.

    Hi all,
    I'm trying to make a button which scales up on rollover and
    scales down on rollout and I wanted to use the Tween class to do it
    because I'm going to be making a bunch of these buttons and I want
    the code to be as efficient as possible.
    So right now I have a circle in a movie clip, and here's what
    I have on the first frame of that circle's actions layer:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    function grow(who) {
    var tw:Tween = new Tween(who, "_xscale", Strong.easeOut,
    100, 400, 1, true);
    var tw2:Tween = new Tween(who, "_yscale", Strong.easeOut,
    100, 400, 1, true);
    function shrink(who) {
    var tw3:Tween = new Tween(who, "_xscale", Strong.easeOut,
    400, 100, 1, true);
    var tw4:Tween = new Tween(who, "_yscale", Strong.easeOut,
    400, 100, 1, true);
    this.onEnterFrame = function() {
    trace(rewind);
    if (rewind == true) {
    shrink(this);
    this.onRollOver = function() {
    rewind = false;
    grow(this);
    this.onRollOut = function() {
    rewind = true;
    The circle scales up just fine but when I rollout it doesn't
    scale back down. I did a trace to see if my tween was being called
    and sure enough it was. So I did another trace to see if the
    _xscale or _yscale was changing and they both were going down to
    around 290 on rollOut although there's no noticeable difference in
    the size of the button, it just looks like it's sitting there.
    I was also wondering if importing the whole class library
    will add very much to my file size?
    Also, since I'm going to have a lot of these buttons on the
    stage at the same time (these buttons will be like markers all over
    a map so there'll probably be around 50+) would it be a bad idea to
    have that many onEnterFrame checks running simultaneously? Is that
    going to slow the user's CPU way down?

    Thanks for the suggestions guys.
    I tried your code and got the rollOut to work but the button
    blinks rapidly if the user rolls out and then rolls back in
    quickly. Here is a link to the swf:
    http://www.stationarynotes.com/studioI/buttonTest.swf
    It also has to reach a complete stop the first time the
    button expands or else it won't run the shrink function on rollOut.
    I put all of my code on the first frame of the movie clip's
    actions layer so here's what mine looks like:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    function grow(who) {
    var tw:Tween = new Tween(who, "_xscale", Strong.easeOut,
    100, 400, 1, true);
    var tw2:Tween = new Tween(who, "_yscale", Strong.easeOut,
    100, 400, 1, true);
    tw.onMotionFinished=function():Void{
    who.onRollOut = function() {
    shrink(who);
    function shrink(who) {
    var tw3:Tween = new Tween(who, "_xscale", Strong.easeOut,
    400, 100, 1, true);
    var tw4:Tween = new Tween(who, "_yscale", Strong.easeOut,
    400, 100, 1, true);
    this.onRollOver = function() {
    grow(this);

  • My 2007 Intel iMac is waking from sleep on its own during the early morning hours. Not sure why. Is there a way to find out by looking at some sort of log files or something else?

    I'm wondering if someone else is having control of my iMac as it randomly wakes up from sleep while I am sleeping sometime during the night. I've woken up with the light from the monitor brightening my room. Need to find out what is causing it to wake up and stay on. Any suggestions?

    I've had this same issue lately. Here's one thing to check: System Preferences > Energy Saver > Wake for Network Access should be unchecked.
    Mine is unchecked, so the only other thing I can think of is that it might be Time Machine backing up. My iMac is backing up to an external hard drive, and also sharing that drive over the network so two other Macs can back up as well.
    Should be an easy theory to test. Turn off AirPort, unplug Ethernet, and let the iMac sit. See if it still happens.

  • How do I prevent Lightroom from creating duplicates if the edit in photoshop is not saved?

    Hello!
    How do I prevent Lightroom from creating duplicates if the edit in photoshop is not saved?
    So... Quite often I choose to 'Edit in photoshop' from Lightroom but then end up not saving the result. (for example, because I just wanted to experiment with the photo, or I'm not satisfied with the results)
    However, Lightroom always creates a copy of the original photo, which stays in the catalog even if the photoshop changes aren't saved.
    Is there a way to stop this, and only add a photo if it has been edited in PS?
    Using LR5 with PS CS6 on a Mac 10.9
    THANK YOU!

    Select 'Open the Image in PS as a Smart Object'. The image will be rendered by ACR in memory without being written to disc until you save it from within PS.

  • RIDC api: The result set 'content' was not found or is empty

    Hi,
    I am trying to add a revision using COLLECTION_CHECKIN_REVISION. The content which I want to add a revision has only one revision i.e. 1,
    and its dID is 3746 and is already checked out.
    <code>
         binder.putLocal ("IdcService", "COLLECTION_CHECKIN_REVISION");
         // get the binder
         binder.putLocal ("dDocTitle", "Html file");
         binder.putLocal ("dDocName", "SUN00100");
         binder.putLocal ("dDocType", "Document");
         binder.putLocal ("dSecurityGroup", "Public");
         binder.putLocal("hasCollectionID", "true");
         binder.putLocal("dID", "3746");
         binder.putLocal("dRevLabel", "2");
         binder.putLocal("dCollectionID", this.getFolderIdFromPath(idcClient, userContext, PATH));
         System.out.println("dCollectionID###############################" +binder.getLocal("dCollectionID"));
         binder.addFile ("primaryFile", new TransferFile(new File("D:\\P6WS\\RIDC Test\\src\\com\\oracle\\ridc\\poc\\2.html")));
         // checkin the file
         response = idcClient.sendRequest(userContext, binder);
         System.out.println("response "+response.getResponseAsString());
    </code>
    And the output is as follows
    dCollectionID###############################739373434448003784
    response <?hda version="11gR1-11.1.1.5.0-idcprod1-110413T184243" jcharset=UTF-8 encoding=UTF-8?>
    @Properties LocalData
    deleteCompleteInCollections=true
    dDocType=Document
    refreshSubMonikers=
    dUser=sysadmin
    anyState=true
    primaryFile=2.html
    StatusMessage=<strong>The result set 'content' was not found or is empty.</strong>
    UserTimeZone=UTC
    localizedForResponse=1
    dDocName=SUN00100
    changedMonikers=
    I want to understand which content is being referred. The primaryFile is existing in the same location.
    Did I missed out any required parameter.
    regards,
    Sunil Kumar Dhage
    Edited by: 881595 on Aug 26, 2011 4:18 AM

    Like last time: documentation is not a big help here, so you have to do a bit of investigation yourself.
    In order to understand result sets, check this link: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10726/c04_master_usage.htm#CSIDO249
    ('content' is the name of the result set)
    I can't imagine why you would need such a result set while checkin in a new revision to a folder, but the documentation (http://download.oracle.com/docs/cd/E17904_01/doc.1111/e11011/c08_folders.htm#i1082329) advices that some sub services are called, so it might actually be an error coming from these subservices. I'd suggest to narrow down the search first - turn on requestaudit in server-wide tracing (see here: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10792/c02_processes.htm#CSMSP536).
    Alternatively, you could also perform your service call from GUI and trace what parameters are provided. I guess something will be missing.

  • HT1386 I have an older iPhone (3gs) and need to upgrade to a newer phone (4S).  I need to get my NOTES, CALENDAR, CONTACTS, PICTURES, etc backed up on iTunes so I can get that data loaded onto the new phone.  But not sure how to do that.

    I have an older iPhone (3gs) and need to upgrade to a newer phone (4S).  I need to get my NOTES, CALENDAR, CONTACTS, PICTURES, etc backed up on iTunes so I can get that data loaded onto the new phone.  But not sure how to do that.  When I open iTunes it has a button that say "Back Up iPhone", but I'm not sure what that does.  When I go into the sync options it say I have another user account and asks me if I want to merge of replace. I'm assuming it's trying to tell me I have an older iTunes Library, but don't know that.  Geez, maybe people over 60 shouldn't have iPhones, iTunes just bafles me.

    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf

  • My Ipod Touch 5 got a long red line all of the sudden on the screen and i do not know why

    Hello,
    So i have purchased my Ipod Touch 5 through apple. The thing is, i do not know why a red long line appeared on my screen all of the sudden. It has not fallen at all so i was just wondering if there is the possibility of sending my ipod into apple and getting another one since i have warranty.

    Try:
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings                            
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes      
    - Restore to factory settings/new iOS device.                       
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                                                              

  • I received a text today while at work about iCloud keychain verification code. I have not signed up for it or anything that uses it. I work out of the city with limited internet access so not sure why I would be getting this. Is my info safe??

    I received a text today while at work about iCloud keychain verification code. I have not signed up for it or anything that uses it. I work out of the city with limited internet access so not sure why I would be getting this. I only got this number about a month ago. Apparently someone else had the number before because I get texts from his family members wondering whats going on. I got one yesterday and the person didn't seem to thrilled that the number was cutoff and today I got 2 texts about iCloud Keychain which I don't even know what it is. Seems suspicious to me. If the person who use to own the number is doing it he should know it is not his number anymore because he obviously didn't pay his bills.  I'm not too sure about iCloud Keychain so just want to know my info safe?? It says it can store credit card numbers which is what gets me worried. Frankly I think it's pretty stupid to save that kind if information with any kind of app. But I don't want some random person trying to access my personal information because they are bitter they lost their number.  Please let me know as soon as possible so I can change passwords or anything that is needed.
    thanks

    If it were me, I would go to my carrier and get a new number. Since you have only had it for a month, the inconvenience would be minimal.
    Barry

  • From some reason (i'm not sure why..) my whole iphoto library got deleted. I restored the whole library from my backup. The photos are blank but steel have the photo info. (date, res., size etc.) Do you know what's the prob.? why can't i see my pics.

    from some reason (i'm not sure why..) my whole iphoto library got deleted. I restored the whole library from my backup. Now all the photos are blank but steel have the photo info. (date, res., size etc.) Do you know what's the prob.? why can't i see my pics.

    It's says that file does not exist. How come? And why does it still show the image info.?
    Where can i find those files (i have a daily backup)
    The original image files are missing form your iPhoto library or iPhoto cannot find them, because the link to the originals has been broken. The image info is stored in the internal libraries, independent of the original files. That is, why you are still seeing them.
    I restored the whole library from my backup.
    Try restoring from an older backup, from before you first noticed the problem. 
    How large is the library, that you restored? Is the file size large enough to hold all your photos, or has the size been reduced?  If the library is still large, the photos may still be inside, even if iPhoto cannot find them.
    It's says that file does not exist. How come?
    What happened, before your iPhoto library got deleted? Which applications have you been running, or which new software have installed or upgraded?  Have you moved the library to a different disk or tried to use it from different user account or access it over the network?

  • Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Yes - email &amp; text work fine but when I use something like Google Images or search a blog with imbedded photos I get the empty white boxes with question marks.  If I click the question mark it opens the photo but I can't possibly do that for EVERY image on EVERY page I search!?!?!  I've rebooted the iPad &amp; my wireless card several times but neither action helped.  Have any clue what I should do now?

  • Hello, I just did an update and now the second Language - Hebrew - does not working. why?

    Hello, I just did an update and now the second Language - Hebrew - does not working. why?

    More information please.
    If you are on adobe cloud, download indesign that support hebrew from CC desktop. Click on the preference gear on the top right then select App language.

  • My iphone5 crashed Wed May 29 and I am not sure why.. I had to do a restore and have been trying to slowly get everything back on the phone... Yesterday June 6 it blacked out once and I don't have everything on the phone as before.... New one?

    My iphone5 crashed Wed May 29 and I am not sure why.. I had to do a restore and have been trying to slowly get everything back on the phone... Yesterday June 6 it blacked out once and I don't have everything on the phone as before.... Is it damaged and should I try to get a new one?

    Thank you again for all of your help!! I really appreciate it!
    I think I am following -- I was able to upload to my iPhoto and all photos and videos are there that is a plus! I tried to create an Event in my iPhoto and put all of my photos in that event but for some reason, now my iTunes it not recognizing that Event in my iPhoto. It is not allowing me to import just that event at the moment but I may be doing something wrong. At least all of my pics and vids are in iPhoto so that is a plus and I know they are at least saved somewhere. Just for some reason, my iTunes it not locating the event that I created with only those photos.
    Thank you for letting me know about my contacts! How do I know if I have the contacts app?
    Also, I had no clue that my iCloud could be backed up via cellular data! However, is this a new feature with the most updated iOS?? Unforutnatly I am like 2 iOS updates behind because I don't have enough storage on my phone. I still get the notification that my phone needs to be plugged in and connected to wifi in order to back up to the cloud :-(
    How can I sync using USB? Right now when i click on the info tab for my iPhone in my iTunes this is the answer that I get -- I am a little unclear as to what it means.
    Sync Contacts:
    Your contacts are being synced with you iPhone over the air from iCloud. Over-the-air sync settings can be changed on you iPhone
    Sync Calendars:
    Your calendars are being synced with you iPhone over the air from iCloud. Over-the-air sync settings can be changed on you iPhone

  • HT3775 I am not able to convert movies, keep getting this message The document "The Walking Dead Trailer - YouTube-2.mp4" could not be opened. The movie's file format isn't recognized. not sure why, anybody know

    I am not able to convert movies, keep getting this message The document “The Walking Dead Trailer - YouTube-2.mp4” could not be opened. The movie's file format isn't recognized. not sure why, anybody know

    Sounds like someone ripped the movie off of YouTube and it got corrupted in the process. Try getting the movie file again, or try using an alternative movie player such as VLC: http://www.videolan.org

  • Trying to set up mail and iCloud in iPhone4.  It keeps saying verification failed. the request timed out. Not sure what to do,

    Trying to set up mail and iCloud in iPhone4.  It keeps saying verification failed. And the request timed out?  Not sure what to do.  I do have an iCloud account and am able to log on to it on computer and see mail, contacts, etc.  Any ideas?
    thanks for any help

    ausask64 wrote:
    Can't seem to get a connection to internet even thou it tells me i have one. 
    If you see the white WiFi bars in the upper left corner, that simply means that the iPad has detected a WiFi network, and that does not mean that you are connected to the Internet.
    Can you open web sites with Safari?

  • Has there been trouble with the charger.  I am getting to re-order but the one i had the had the power surge and the end was blackened.  Not sure if it safe to use the laptop again?

    Has there been any trouble with the charger?  I am getting ready to re-order but the one i had.... the had the power surge and the end was blackened.  Not sure if it safe to use the laptop again?  Thanks.

    Can you also see blackening in the power jack on the PowerBook? If so, I would be worried that the surge also damaged the computer/
    Does the computer run OK on just the battery? If it is working on battery power, that limits the number of things inside the computer that could have been fried.
    If the computer is severely damaged by the surge, it's not worth repairing. However, a couple of posters in Apple forums said their homeowners'/renters' insurance paid them replacement value of their computer after power surge damage due to known problems on the grid, like the huge power outage that hit the SW Untied Stats and part of Mexico yesterday.

Maybe you are looking for

  • How to update two tables in a single call using JDBC Sender adapter

    Hello All, The scenario is, database entries have to be selected from two tables and at the same time those tables have to be udpated with the flag. We are using JDBC sender adapter and in Select Query, we are fetching the data by joinin the two tabl

  • Hyper-V 2012 r2 Clustering issue

    Hi All We have the following issue and I just thought of why this could be happening We are using a 3 node cluster with a witness disk The problem is that the nodes in the cluster fail daily and its not a specific node it happens to any of them, but

  • How do you sync your old library to a new laptop?

    Hi, Im currently using a new laptop and wanted to know how can I sync the library I had in the previous one to the new one. When I connect the ipod to the new one, I get a message that says that my Ipod is connected to a different library or somethin

  • Wrong date format when creating a universe based on a MS Analysis cube

    Hi, When creating a universe based on a MS Analysis 2008 cube the date objects from the cube are created in the universe with CHAR format when it should be DATE format I have tried to resolve the issue by modifying the date object in the universe wit

  • Spinning ball on imovie,what to do to complete project

    working on project in imovie,but spinning ball appeared and can no longer get imovie to respond