VMware Cloud Community
BostonTechGuy
Enthusiast
Enthusiast

Posting Code in Discussion Question

How is everyone here posting code so it looks like it came right out of PowerGUI??

When I post code it just looks like text.

Thanks

Boston Tech Guy

0 Kudos
4 Replies
a_p_
Leadership
Leadership

Take a look at LucD's document at Some ways to enter PowerCLI code under the new forum SW

André

0 Kudos
LucD
Leadership
Leadership

Mind, when it is only a couple of lines of code, I use the Advanced Editor - Insert - Quote option as well Heart


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BostonTechGuy
Enthusiast
Enthusiast

Cool!  Lets see

THIS IS MY CODE.

LOOK IT WORKED

AND

              

Connect-VIServer "myvcenter"
$byebye = (Get-Content "C:\Scripts\Delete\bye.txt")
Foreach ($vm in $byebye)
{
   
IF ($vm.PowerState -eq "PoweredOn")
    {
       
Stop-VM -VM $vm -Confirm:$false
    }
   
ELSE
    {
       
Write-Output $vm "IS OFF"
    }
}   
Disconnect-VIServer -Confirm:$false

Too bad you have to enter the "<br />" code at the end of lines.

So who gets the points for Answering this question:  Andre for replying to the post or LucD for creating the Document :smileylaugh:

Thanks

Boston Tech Guy

0 Kudos
a_p_
Leadership
Leadership

Don't worry about the points and rather use the information to help other users with posting helpful code. Smiley Wink

If you want to award points anyway, it's Luc who deserves them. I just pointed you to his documentation.

André

0 Kudos