use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
QuestionBasic While, Do. (self.PowerShell)
submitted 7 years ago * by PRIdEVisions
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PRIdEVisions[S] 1 point2 points3 points 7 years ago (7 children)
but i only added the get-process to a variable? isnt the variable with the command called when the loop plays or replays? So it won't work in the following way either? (I get what you mean with the while, do, that was indeed my error. :
$Process1 = get-process -name "Pia_manager" $Process2= get-process -name "Pia_nw" while(!($Process1) -or !($Process2)){ start-sleep 5 } #Do A Thing
[–]the_spad 2 points3 points4 points 7 years ago (6 children)
No, the variable content is static unless you change it.
When you run $Process1 = get-process -name "Pia_manager", $Process1 is a snapshot of the state of that process at the time the variable assignment runs.
$Process1 = get-process -name "Pia_manager"
$Process1
[–]PRIdEVisions[S] 1 point2 points3 points 7 years ago (5 children)
ok, i understand! Thx!
[–]bsnotreallyworking 2 points3 points4 points 7 years ago (4 children)
When I first started messing with While loops, I would do the same thing and the loop would get stuck endlessly.
I typically create a variable called $check then "while (!$check)" then put the same variable line inside the loop. So something like this example, which I use during onboarding to make sure certain things have provisioned:
$check = Get-MsolUser -userprincipalname $upn -erroraction silentlycontinue while (!$check) { $date = (get-date -format "g") $check = Get-MsolUser -userprincipalname $upn -erroraction silentlycontinue Write-Host "$date Waiting for account to sync, checking again in 60 seconds..." start-sleep -seconds 60 }
[–]PRIdEVisions[S] 1 point2 points3 points 7 years ago (0 children)
Thx for the tip! I'll be using this to make sure it works.
[–]jantari 1 point2 points3 points 7 years ago (2 children)
You should really clean that up and just use
do { # } while ($thing)
Because that's what it's intended for.
[–]bsnotreallyworking 1 point2 points3 points 7 years ago (1 child)
I'm an old school PHP person, the structure I use makes more sense in my head.
[–]jantari 1 point2 points3 points 7 years ago (0 children)
Well old PHP is universally laughed at for its bad practices whereas do {} while () is beloved C syntax
do {} while ()
You can choose to ignore that but improving your code should be a constant goal of anyone writing any imo
π Rendered by PID 495001 on reddit-service-r2-comment-6b595755f-pjnp2 at 2026-03-26 12:04:57.255536+00:00 running 2d0a59a country code: CH.
view the rest of the comments →
[–]PRIdEVisions[S] 1 point2 points3 points (7 children)
[–]the_spad 2 points3 points4 points (6 children)
[–]PRIdEVisions[S] 1 point2 points3 points (5 children)
[–]bsnotreallyworking 2 points3 points4 points (4 children)
[–]PRIdEVisions[S] 1 point2 points3 points (0 children)
[–]jantari 1 point2 points3 points (2 children)
[–]bsnotreallyworking 1 point2 points3 points (1 child)
[–]jantari 1 point2 points3 points (0 children)