header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Bug in PS ISE
Last Post 31 Aug 2010 06:06 PM by Marco Shaw (MVP). 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
valdezdjUser is Offline
New Member
New Member
Posts:96
Avatar

--
31 Aug 2010 10:26 AM
    Ok, so i have this script that pings each computer in AD and exports the list to a csv file. But when I run the script in PS ISE it runs most of the script but then restarts itself into a never ending loop and I have to do a Ctrl+C to end the script. When I debug the script in ISE to see where it fails it restarts when I create a variable to ping the computers. I'm using the ping-computer cmdlet that's part of the PSHX-SAPIEN cmdlets. Then when I create that same variable in the powershell side not the ISE part but a new instance of powershell it works fine and when I run the script in a new instance of powershell it runs fine also.
    Here's the script:
    [script removed]
    valdezdjUser is Offline
    New Member
    New Member
    Posts:96
    Avatar

    --
    31 Aug 2010 10:35 AM
    For some reason the script was removed so here you go.

    $loc = Read-InputBox -message "Enter a location" -title "Division"

    set-variable path1 -scope script
    $script:path1 = "C:\Scripts\Output\computersping$loc.csv"
    set-variable path2 -scope global
    $global:path2 = "C:\Scripts\Output\PingCompsNew$loc.csv"

    $start = Get-Date
    $starttime = "{0:T}" -f $start
    Write-Host "Started at $starttime"
    Write-Host `r

    Function Pinger{

    $domainroot = "domain/OU/$loc/Computers"
    $Computers = Get-QADComputer -SearchRoot $domainroot -SizeLimit 0 -DontUseDefaultIncludedProperties |Select Name | Sort-Object Name| Export-Csv -path $path1 -noTypeInformation | Format-List Name
    $pingers = Get-Content $path1

    #ping each computer for success
    $array = @()

    foreach ($Comp in $Pingers){
    $comped1 = $comp.TrimStart('"')
    $comped = $comped1.TrimEnd('"')
    $comped
    #This is where the script restarts. ???
    $PingResult = ping-computer -name $Comped

    $computer = (Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Comped -ea silentlycontinue)
    $customset = ""|Select-Object Name, Username, IPAddress, StatusCode, Model
    $customset.Name = $Comped
    $customset.IPAddress = $PingResult.ProtocolAddress
    $customset.StatusCode = $PingResult.StatusCode
    $customset.Model = $computer.model
    $customset.Username = $computer.username

    #Test if the computer returns an IP address
    if($PingResult.ProtocolAddress){

    $array += $customset
    }
    }
    $array|where{$_.Name -ne 'name'}|?{$_.Name -notlike '*fps' -and $_.IPAddress -ne ""}|Sort-Object Name|Select Name, Username, IPAddress, StatusCode, Model|Export-Csv $path2 -noTypeInformation

    }

    if(!(Test-Path $path1)){
    Pinger
    }
    else{
    Remove-Item $path1
    Pinger
    }
    Write-Host `r
    $end = Get-Date
    $endtime = "{0:T}" -f $end
    Write-Host "Finished at $endtime"

    If this is a bug how do I report it?
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1642
    Avatar

    --
    31 Aug 2010 06:06 PM
    I've not tried it. Unless you are the developer of a 3rd party app and/or have the actual source code, I don't think Microsoft will consider spending time on this. I'd go with reporting this to Sapien. They have a "free tools" forum here: http://support.sapien.com/forum/
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer