Stop script from repeating

Welcome Forums General PowerShell Q&A Stop script from repeating

This topic contains 3 replies, has 3 voices, and was last updated by

js
 
Participant
2 weeks, 4 days ago.

  • Author
    Posts
  • #113225
    cm

    Participant
    Points: 0
    Rank: Member

    Excuse the formatting.

    https://pastebin.com/ZDEPbgYH

    The script takes about a minute to run. I'm displaying the results within a RichTextBox inside a GUI. While the script is parsing through the OU, it repeats the servers that it does find with less than 10GB, until the script completes. I need it to display what servers it finds just once. I've tried Break and Continue which don't work.

    TIA

    P.S. I know I need to update the code to use Get-CIMInstance and Win32_Volume

  • #113264
    cm

    Participant
    Points: 0
    Rank: Member

    Never mind, I figured it out. I had my Add-RichTextBox $results in the wrong place.

  • #113267

    Participant
    Points: 65
    Published
    Rank: Member

    Please post the script here or use gist, it will be difficult for anyone to open another link to go through your script.

    Please not that, you are iterating through all the computers in the domain.
    -ComputerName parameter takes array of strings, hence you could avoid using Foreach loop.

  • #113269
    js

    Participant
    Points: 9
    Rank: Member

    Get-PSDrive shows free space too.

You must be logged in to reply to this topic.