Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need help creating a while loop

$
0
0

I have a script that is being used to shut down a UCS blade server - here is a code snip:

try { 

    if ( $ProfileFull.Operstate -eq "ok" ) {

        Get-UcsServiceProfile $ProfileId | Set-UcsServerPower -State soft-shut-down -force

        start-sleep -s 120

        wait 150

    }

#########

I want to change the code to add in a while loop that waits for the blade to power off... what is the best way to do that? Would this work?

try { 

    if ( $ProfileFull.Operstate -eq "ok" ) {

        Get-UcsServiceProfile $ProfileId | Set-UcsServerPower -State soft-shut-down -force

            $bladeDn = $ProfileFull.PnDn

            while ( Get-ucsblade | ?{$_.Dn -eq $bladeDn } ?{$_.OperPower -eq "on" ) {            

                  start-sleep -s 120        

            }

    }


Viewing all articles
Browse latest Browse all 6937

Trending Articles