Explanation for some commands

Hello

I am new to poewrcli and will work with her over the next while. Can someone explain the following for me please? If someone could put beside each line comments to explain the syntax in its entirety, it would be great. This isn't just a script, it is a mixture of different lines that I don't understand

$folder = get-file $folderName | where {$_.name - eq $cell_id}-indicated, it's an internal thing so ignore that

Write-host - ForegroundColor green "verification that the hosts are added by the correct format".

ForEach ($VMhostname to ($folder |)) Get - VMHost - name $VMhost). Sorting)

$VMhostname = [string] $VMhostname

If (($VMhostname-eq $Esxihost) - or ($VMhostname - eq $Esxihostb))

Write-host - ForegroundColor green $VMhostname successfully added

Write-host $Esxihost $Esxihostb

}

on the other

{

$folder = get-file $folderName | where {$_.name - eq $cell_id}

ForEach ($VMhostname to ($folder |)) Get - VMHost - name $VMhost). Sorting)

{

$hostnameedit = $VMhostname.name.split(".") [0]

$dsname = $hostnameedit + "-local".

Get-VMHost $VMhostname | Get-Datastore-name * | Store game data-name $dsname

VirtualSwitch get - VMHost $VMhostname | Get-NicTeamingPolicy | Game-NicTeamingPolicy - MakeNicActive vmnic1

}

New-OSCustomizationSpec-name $OSCostumSpec_VC - Windows - $VMPassword AdminPassword OSType - zone ProductKey - $WinProductKey_VC - ChangeSid - OrgName $OrgName - NamingScheme $TimeZone fixed NamingPrefix - $VCVM.split(".") [0] - fullname administrator - workgroup WORKGROUP

$folder = get-file $folderName | where {$_.name - eq $cell_id}

ForEach ($VMName to ($folder |)) Get - VM - name $VMMac). where {$_.} PowerState - eq "PoweredOff"} | Sorting)

{

Start-VM - $VMName VM - confirm: $false

Commands PowerCLI and PowerShell can be read as the English text. For example, the Get-application cmdlet retrieves one or more folders. Comment in a script can be started with the sign #. I'll give comment to each line of the first time it occurs.

# Recover a folder with the name $cell.id and put it in the $folder variable. Can be written more short as:

# $folder = get-file-name $cell_id

$folder = get-file $folderName | where {$_.name - eq $cell_id}-indicated, it's an internal thing so ignore that

# Write a line to the console in green color.

Write-host - ForegroundColor green "verification that the hosts are added by the correct format".

# Retrieve the ESXi host with the name $VMHost in the $folder folder, sort hosts based on the names and put one up for a # in the $VMHostName variable. In this example, the variable $VMHostName contains VMHost and not the name of the host objects #. If you want to get the names, you must use:

# ForEach ($VMhostname to ($folder |)) Get - VMHost - name $VMhost). Sort-Object. Select-Object - ExpandProperty name)

ForEach ($VMhostname to ($folder |)) Get - VMHost - name $VMhost). Sorting)

# Make sure that $VMHostName is a string by using the [channel] type conversion

$VMhostname = [string] $VMhostname

# Compare $VMHostName with $Esxihost or $Esxihostb

If (($VMhostname-eq $Esxihost) - or ($VMhostname - eq $Esxihostb))

{

# Do this part if the result from the previous comparison is $true

Write-host - ForegroundColor green $VMhostname successfully added

Write-host $Esxihost $Esxihostb

}

on the other

{

# Do this part if the result from the previous comparison is $false

$folder = get-file $folderName | where {$_.name - eq $cell_id}

ForEach ($VMhostname to ($folder |)) Get - VMHost - name $VMhost). Sorting)

{

# Splits the string in the variable $VMhostname in the points and take the first piece.

$hostnameedit = $VMhostname.name.split(".") [0]

# Add two strings

$dsname = $hostnameedit + "-local".

# A data store to a new name

Get-VMHost $VMhostname | Get-Datastore-name * | Store game data-name $dsname

# Put the NIC teaming policy and make vmnic1 active NETWORK card

VirtualSwitch get - VMHost $VMhostname | Get-NicTeamingPolicy | Game-NicTeamingPolicy - MakeNicActive vmnic1

}

# Create a new OSCustomizationSpec

New-OSCustomizationSpec-name $OSCostumSpec_VC - Windows - $VMPassword AdminPassword OSType - zone ProductKey - $WinProductKey_VC - ChangeSid - OrgName $OrgName - NamingScheme $TimeZone fixed NamingPrefix - $VCVM.split(".") [0] - fullname administrator - workgroup WORKGROUP

$folder = get-file $folderName | where {$_.name - eq $cell_id}

# Retrieve the virtual machines that are powered to folder $folder and sorting them based on the names.

ForEach ($VMName to ($folder |)) Get - VM - name $VMMac). where {$_.} PowerState - eq "PoweredOff"} | Sorting)

{

# Start a virtual machine with the name of $VMName and do not ask for confirmation

Start-VM - $VMName VM - confirm: $false

Tags: VMware

Similar Questions

  • Plugin Check gives poor results for some Mac

    On a Mac under OS X 10.6.8 (Snow Leopard) or versions earlier, Plugin check mark indicates the Applet Java plug-in and QuickTime plug-ins are obsolete.

    Steps to reproduce:
    Tools-> Add-ons-> Plugins-> check to see if your plugins are up to date

    The results show:
    Java Applet plugin update now
    QuickTime plugin 7.6.6 update now

    Explanation:
    1. before Apple OS X 10.7 (Mountain Lion) provided Java. Apple did not provide an update. [thejava.com siteupdate requires Mac OS X (10.7.3 version and above)]
    2. There is no update QuickTime plugin 7.6.6 for some Mac; It is a more recent OS x 10.6.3 via 10.6.8.

    Plugin Check can be fixed?
    Macs can get better help? (Some bugs without go back to Firefox 3.5 and before!)

    I see your vote in: Bug 565832 - Plugin Check indicating QuickTime plugin 7.6.3 is "Obsolète"

    7.6.6 also reported

    do not have a new bug, it's ok. (I vote also)

    Thank you

  • How can I stop auto correct for some words?

    How can I stop auto correct for some words?

    Here's a great explanation and solution:

    mamadi http://coolestguidesontheplanet.com/turn-AutoCorrect-OSX-Mac-mail-Skype-10-9-MAV.

  • RemoteScan is not for some users

    I recently installed RemoteScan on a new machine and got all this work in one programs installed on the RDS Server. In the other program requiring analysis, RemoteScan appears only for some users. I tried to recreate the user profile. I tried to copy it to the file remote.ini of a profile that works. I tried to reinstall RemoteScan on the workstation, but so far nothing has solved the problem. I have no idea what could be the cause and was hoping that someone could have encountered the same problem. Any help would be greatly appreciated.

    RemoteScan files must be in the user homepath. These files should be as follows:

    TWAIN_32 (folder... RemoteScan internal folder)
    TWAIN_32.dll 44KO
    Twunk_32.exe

    All these RemoteScan files should be in the folder windows homepath from the user. To confirm the homepath from the user, you need to connect to the server as the user and then display a command prompt. Type set home.

    If you have questions contact RemoteScan to 406-721-0276.

    Thank you

  • My network firewall has been disabled for some reason.

    Original title: NetworkFireWall

    My network firewall has been disabled for some reason. And I don't know how I start it again? When I look in the action center you can activate it again I find and I press Activate and nothing happens? So my action center do not work? Or what it is - this? Help, please.

    My network firewall has been disabled for some reason. And I don't know how I start it again? When I look in the action center you can activate it again I find and I press Activate and nothing happens? So my action center do not work? Or what it is - this? Help, please.

    (1) you have a third-party security software installed?
    This could be due to that... What are the analyses of different viruses that you already have... It may be a product of firewall or security of third parties that interfere the windows firewall, disable one by one your security scanners and try for windows firewall

    (2)if you do not have these installed firewall products, this could be due to malicious software or some other problem...

    If you have an antivirus up to date solution its definitions and do a full scan of the system...

    If you do not have an antivirus solution, or one does not work, use one of the recommended tools (use only one at a time)

    http://www.Microsoft.com/security/scanner/en-us/default.aspx
    And/or
    http://www.Malwarebytes.org/products/malwarebytes_pro/
    And/or
    http://www.simplysup.com/tremover/download.html (shareware)
    And/or
    http://www.McAfee.com/us/downloads/free-tools/Stinger.aspx
    And/or
    http://www.Kaspersky.com/free-virus-removal-tool

    If this also isn't that the problem may be that your firewall service is damaged...

    (3)
    open a command prompt run as administrator and type sfc/scannow

    (4) try to fix the firewall service
    Run the tool repair services by ESET
    http://KB.ESET.com/library/ESET/KB%20Team%20Only/Malware/ServicesRepair.exe


    And/or
    Download and add this firewall Windows registry entry - download.bleepingcomputer.com/win-services/7/MpsSvc.reg
    (If you find difficulties to add to the registry to refer this http://www.windowstechinfo.com/2013/07/solved-cannot-import-to-registry-not.html)

    And/or
    Open a command prompt using run as administrator
    and copy - paste these
    Rundll32 setupapi, InstallHinfSection Ndi-Steelhead 132 %windir%\inf\netrass.inf
    and press enter

    (4)(run as administrator) command prompt, type netsh advfirewall reset , and press "enter."

  • See load test: ways to script for applications commands?

    Hello

    I'm designing a simple tool for an environment of view and so far its goes pretty well load test.  With the help of command line arguments and some Powershell, I am capable of recursion through a list of users and connect multiple sessions on a display server and open office and a few RDS App sessions.  My question is: is there a built-in way to pass a script in the command line arguments run certain commands on this computer to office or RDS App session?  Nothing crazy, just type in Notepad, open a few programs, save a doc or two--the usual stuff to generate regular workloads.

    I know that VMware and third party companies have tools for this, but they don't specifically meet my needs without extensive configuration and a lot of hooks in our systems.  I'm trying to keep the footprint of this test as small as possible, so a simple Powershell script is how I want to move forward.  I guess that Powershell has a method to do this, but I'm not guru script nor it is a PS forum, so I was hoping there was something that already exists when I call the view connection that I could use.

    Any help is appreciated, thanks in advance!

    I can not completely solve your problem, but it can be a little simpler.

    Q. for the "is there a built-in way to pass a script in the command line arguments run certain commands on this computer to office or RDS App session?

    A. No, but you can use strategies Group (GPO) that can be activated when his connection to run a script.

    BTW, for others who read this blog, "VMware View Planner" is the internal tool that can be used by customers too much for some areas of load test: VMware View Planner | United States

  • I've recently upgraded to CS6. For some reason any floating document windows that I move in the workspace, pull out the interface, especially to the left and sometimes to the bottom of the screen. I gave tried Essentials rearmament and Interface to d

    I've recently upgraded to CS6. For some reason any floating document windows that I move in the workspace, pull out the interface, especially to the left and sometimes to the bottom of the screen. I gave tried Essentials rearmament and default setting Interface. A message letting me know that by default has been reset but I still have the problem. It's SO frustrating as a large part of the time I can't go to the window, I want to work on. Help, please!

    Hi John

    Try resetting preferences

    Press and hold the CTRL, ALT, shift (Windows) / command Shift (MAC) Option in starting up of Photoshop.

    Select Yes

    Note:-make sure you backup Presets/stock/Modified Workspaces/Plugins (if any)

    Thank you

    Assani

  • Save for web command keyboard no longer works

    I have Photoshop on Mac OS 10.9.2 CC.

    For some reason I can't understand, shift-Option-command-S is no longer opens "Save for web" dialog box  There is no nothing.

    I can open the dialog box in the menu itself, no problem; It's just the shortcut that failed.

    The shortcut is always visible on the menu as the appropriate command, but it does not work.

    Any thoughts?

    csuebele wrote:

    Sometimes, when you work on a document for a while, my shortcuts keyboard just stop working, and I have to restart the Psalm

    Yes, happens to me too. Try the shift + ctrl + alt + K > Enter. That shortcut still works, oddly enough.

  • object is missing for some users

    Hello
    I have a custom connector and im doing request put in service, but for some users in the form of object-based is just jumping in based provisioning request. I have checked the Group and permissions, and all eyes. can pls someone tell what could be the reason?

    Thank you

    Hello

    I checked "Allow multiple" on the subject of resource and now the form object appears

    I don't understand this... no explanation?

  • How to get the phone and messages back in my dock apps? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    How can I get the phone and messages apps in my dock? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    Try

    Settings > general > reset > reset home screen presentation.

    Note: All other applications will be organised by alphabetical order.

  • Gmail and all the others crash in "Oops!" Google cannot load this page for some reason any

    I am running 10.10.5 and Firefox 41.0.2. Sophos said me no problem.

    In case of Gmail or any other program running in Firefox, the program stops to the message of the screen;
    "Oops!"

    "Google can not load this page for some reason any."

    The box Try Again has no effect.

    However the use of "Most visited" (top of the line LH of Firefox screen) returns to place that quit, without loss of data

    Clear the cache and delete cookies only from Web sites that cause problems.

    "Clear the Cache":

    • Firefox > Preferences > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox > Preferences > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    If the deletion of cookies did not help, then it is possible that the cookies.sqlite file that stores the cookies has been corrupted.

    • Rename (or delete) cookies.sqlite (cookies.sqlite.old) and if present remove cookies.sqlite - shm and cookies.sqlite - wal in the Firefox profile folder in the cookies.sqlite case has been corrupted.

    You can use this button to go to the current Firefox profile folder:

  • I found that if it becomes necessary to use time machine to return to an earlier existence to reinstall the iphoto library, if for some reason, you lose lose, then when you try to synchronize your ipad is not recognized by the computer.  As one

    I found that if it becomes necessary to use time machine to return to an earlier existence to reinstall the iphoto library, if for some reason, you lose lose, then when you try to synchronize your ipad is not recognized by the computer.  So when you try to synchronize the pictures, they are all removed from the ipad and trying to reinstall everything again.

    This may or may not work immediately.  In my case, only half the photos have been installed, and then the error message came that the rest of 9000 can be installed.

    I contacted Apple support team who has made various suggestions.  Subsequently clicking on a photo list in iTunes were all going again and pictures of 9000 then installed.  When I asked the support team what could happen I was told that it was a "glitch".  I don't like seeds they mean that there could be an error in coding somewhere.

    Here me again.  I use an iMac and iPad.  I don't know why XP and iPhone came.

  • The numbers "could not open file for some reason any."

    Suddenly some of my documents of numbers prompt response "numbers" could not open file for some reason any ' "the document is unavailable. Other documents numbers remain accessible. My backup versions invites the same response when I try to open them. Is there a solution?

    Hello Fred,.

    Thanks for this info and choosing the communities Support from Apple. I know how important is able to open all your files in numbers is for you!

    If I understand correctly, you cannot open some files of numbers even from backups, but others continue to work. To limit this problem, I would suggest starting with the following steps:

    1. first of all, run disk utility and check for questions on your hard drive, as hard drive problems can lead to situations like yours.

    Disk utility (Yosemite): a disc repair

    2. then, you can test this in a new user, to refine, if it's a question broad system or specific to your username.

    How to test a question in another account on your Mac.

    See you soon!

  • Firefox 32.0.1 ignores min size of the font for some sites

    Firefox 32.0.1 ignores the setting of font size minimum for some sites.
    For example, http://vk.com or http://javaprogrammingforums.com

    At the top of the dialog box fonts, you will notice a selector 'fonts for"who can tell currently in Cyrillic. To match multiple pages on the web, set the minimum font even for 'Western' and 'Other languages' (pages Unicode covers the latter). -What helps with problem sites?

  • How can I see my recent/favorites contacts? I tried to go to settings to fix it, but for some reason that I don't have the option "show in app.

    I'm seeing my favorite/recent contacts on my phone. I know that you're supposed to go to settings / mail, contacts, calendar and go to the contacts section and click on view in the app, but for some reason button that I do not have this option. Someone knows why?

    Probably since iOS and iOS 9.3.x 9 there is no option, they show right here.

    Get help using iCloud Contacts, calendars, or reminders - Apple Support

Maybe you are looking for

  • I put tabs to open a blank tab, but each new tab has now google search images on it.

    I did not choose as a google search engine - I won't be using google. I have tabs set to open a blank tab each time. I want a blank tab without the google search bar.

  • How to install Win XP on Qosmio G20 using USB flash memory key

    Dear Admin, This is regarding my laptop Qosmio G20. Last month my OS (windows XP media edition) has been corrupted so I attempt to reformat and reinstall the operating system. But unfortunately my CD/DVD-Rom does not work/play,. Then I try to install

  • Updates to Windows XP for may

    I installed the latest Windows XP Home updated successfully, but I receive the reminder message telling me to update these programs, whenever I start. Help!  It is so boring. I've had this computer for one week only - it is a desktop Compaq CQ2000 "r

  • How to paint two ObjectChoiceField on the same line

    Hello Experts! I tried to draw two ObjectFieldChoice on the same line, but the work doesn´t, I found this post that have the same problem as me, but the fix doesn´t works for me. My code: ... String[] tipos = new String[] {"BLA1", "BLA2" }; _tipo = n

  • Computer wake from sleep

    Installed windows 8, the hard drive goes to sleep after 30 minutes as shown in default. When I try to turn on the computer, it looks like the power lights but screen does not work. What's wrong?