Try to understand the problem of script PowerCLI

I'm a Beginner PowerShell CLI rank, but it has been on my list of things to get my head around for awhile, so I was playing with it for a week or two and have managed to solve most of the problems with the search, but for now I'm adapting a PowerCLI script I met a personal project to automate the creation of a vLAB and I don't understand not the problem well enough to be able to properly research could do with a pointer if possible.

The script that I started with is http://poshcode.org/?show=1547

The part of the code that I have problems with is line 25 in the original code that is:

$rpool = for ($i = 0; $i - lt $vmhost.length; $i ++)

If I run just this line from a prompt, I get the same error that is displayed below:

[vSphere PowerCLI] C:\ > $rpool = for ($i = 0; $i - lt $vmhost.length; $i ++)
Lack of closure ")' in the expression."
On line: 1 char: 22
+ $rpool = for ($i = 0; < < < < $i - lt $vmhost.length; $i ++)

I found that if I omit the "$rpool =" then this line of code executes, but then I can't use the results (even if I concede that someone who knows what they might be able to!) )

So, as I understand it well enough to make this code work?

The rest of the script is adapted to my where I created virtual machines from scratch rather than models, environment more I deal with three hosts but except that it is essentially the same.

Pointers appreciated!

(I would have commented on the site hosting the original code, but I couldn't find all the means to do so).

Kind regards

Paul

For me, the command returns the numbers from 0 to 6, all as you would expect. It seems that there is something in your PowerShell session that prevents the statement to run correctly. Looks like you have redefined the command to something else. Maybe an alias or function.

Tags: VMware

Similar Questions

  • The website has encountered a problem and cannot display the page you are trying to view. Take the following steps to try to resolve the problem:

    I get this message when attempting tp establish a connection account Microsoft Update/for the first time "the website has encountered a problem and cannot display the page you are trying to view. Take the following steps to try to solve the problem.

    First of all to clear up your Temp File/Cache, restart the computer and try again. Better and easier to use - CCleaner. http://www.vista4beginners.com/CCleaner> http://www.piriform.com/ccleaner>

    Reboot and reset the Windows Update components with the aggressive part of the correction

    How to reset the Windows Update components?

    http://support.Microsoft.com/kb/971058>

    Reset

    04/09 / 1102:22: 21 pm

  • Problem running script PowerCLI

    Hi all

    I am very new to PowerCLI and I'm looking for someone who can help me with a PowerCLI script I'm running. I found the script online created by someone named Ben on Geekynetworks below.

    When I try and run the script it-error during the New - VM:

    New-VM: A positional parameter cannot be found by accepting the argument '-'.

    C:\VCBScripts\clonetest.ps1:18 char: 8

    Here is the script, can someone tell me what's in it?

    Thanks in advance!

    }

    #To allow script to be run as batch job
    add-pssnapin VMware.VimAutomation.Core

    #declare array of VM names to clone
    $src_vm_names = @("VM_1", "VM_2")

    #connect to server
    Connect-VIServer "vcenter" -User username -Password password

    #Get current date in YYYYMMDD format
    $date = get-date -uformat "%Y%m%d"
      
    foreach($src_vm_name in $src_vm_names){

      $src_vm = Get-VM $src_vm_name

      #create a new clone of the VM
      New-VM -Name ($src_vm_name+"_clone_"+$date) -VM $src_vm -Datastore "remote_datastore" -VMHost "remote_host" -notes $date

      #Permanently delete all clones older than 7 days
      $clones = get-VM ($src_vm_name+"_clone_*")
      $expirydate = Get-date (Get-date).addDays(-7) -uformat "%Y%m%d"
      foreach($clone in $clones){
      if($clone.notes -lt $expirydate){
      Remove-VM $clone -DeletePermanently -confirm:$false
      }
    }

    }

    He should be fine with the add-pssnapin, you have there, moreover, is not to choke on the Get - VM cmdlet that you run earlier, which shouldn't be a problem.

    Make sure that you run in a 32 bit Powershell. The cmdlet New - VM (like one handful of others) will work only in a 32-bit Ppowershell. See:

    https://www.VMware.com/support/developer/PowerCLI/PowerCLI51R2/powercli51r2-releasenotes.html

    The following features of PowerCLI are supported only on 32-bit versions of Windows PowerShell.

    New-OSCustomizationSpec and Set-OSCustomizationSpec

    New-VM and Set - VM (only when it is used to apply customization specifications)

    When running against vCenter Server or ESX/ESXi versions prior to version 5.0, the following PowerCLI functions are supported only on 32-bit versions of Windows PowerShell.

    Invoke VMScript

    Copy-VMGuestFile

    New-VMGuestRoute, Get-VMGuestRoute and Remove-VMGuestRoute

    Set-VMGuestNetworkInterface and get-VMGuestNetworkInterface

    Together-hard drive (only when used for resizing the partitions of comments drive)

    If you run just 'powershell.exe - file path\filename.ps1' of a cmd on a 64 bit OS, it will run the 64-bit default Powershell.

    Run 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe leader path\filename.ps1' to call a 32 bit Powershell.

  • The problem of Script root.sh - ora.asm and ASM and Clusterware battery failed

    People,

    Hello. I want to install Oracle 11 g RAC 2 using 2 VMs (rac1 and rac2) whose BONES are Oracle Linux 5.6 in VMPlayer according to the website http://appsdbaworkshop.blogspot.com/2011/10/11gr2-rac-on-linux-56-using-vmware.html

    I'm installing network infrastructure. On step 9/10 - run script /u01/app/grid/root.sh for 2 virtual rac1 and rac2 machines.

    After running root.sh rac1 successfully. I run root.sh in rac2 and get an error like below:



    [grid root@rac2] #./root.sh
    Run the script root.sh from Oracle 11 g...

    The following environment variables are defined as:
    ORACLE_OWNER = ora11g
    ORACLE_HOME = / u01/app/grid

    Enter the full path of the local bin directory: [usr/local/bin]: usr
    Copying dbhome to usr...
    Copying oraenv to usr...
    Copying coraenv to usr...


    Creating/etc/oratab file...
    Entries will be added to the/etc/oratab file according to the needs of
    Assistant configuration database when a database is created
    Finished to turn the generic part of the root.sh script.
    Now root product-specific actions will be performed.
    2012-03-05 16:32:52: analyzing the host name
    2012-03-05 16:32:52: verification of superuser privileges
    2012-03-05 16:32:52: user has superuser privileges
    Using the configuration settings file: / u01/app/grid/src/install/crsconfig_params
    Create the trace directory
    ADD LOCAL MODE
    Creating OCR keys for the user "root", "root"... privgrp
    Successful operation.
    Adding to inittab demon
    CRS-4123: Oracle high availability Services started.
    starts ohasd
    CRS-4402: the CSS daemon has been started in mode exclusive, but found a CSS daemon that is active on node rac1, number 1 and ends
    An active cluster was found at the exclusive start, start to join the cluster
    CRS-2672: attempt to start 'ora.mdnsd' on 'rac2.
    CRS-2676: beginning of "ora.mdnsd", the successful "rac2"
    CRS-2672: attempt to start 'ora.gipcd' on 'rac2.
    CRS-2676: beginning of "ora.gipcd", the successful "rac2"
    CRS-2672: attempt to start 'ora.gpnpd' on 'rac2.
    CRS-2676: beginning of "ora.gpnpd", the successful "rac2"
    CRS-2672: attempt to start 'ora.cssdmonitor' on 'rac2.
    CRS-2676: beginning of "ora.cssdmonitor", the successful "rac2"
    CRS-2672: attempt to start 'ora.cssd' on 'rac2.
    CRS-2672: attempt to start 'ora.diskmon' on 'rac2.
    CRS-2676: beginning of "ora.diskmon", the successful "rac2"
    CRS-2676: beginning of "ora.cssd", the successful "rac2"
    CRS-2672: attempt to start 'ora.ctssd' on 'rac2.
    Start action for octssd abandoned
    CRS-2676: beginning of "ora.ctssd", the successful "rac2"
    CRS-2672: attempt to start 'ora.drivers.acfs' on 'rac2.
    CRS-2672: attempt to start 'ora.asm' on 'rac2.
    CRS-2676: beginning of the 'ora.drivers.acfs' on 'rac2' succeeded
    CRS-2676: beginning of "ora.asm", the successful "rac2"
    CRS-2664: resource 'ora.ctssd' is already running on "rac2.
    CRS-4000: Start command has failed, or completed with errors.
    Return code of 1 (256) of control: / u01/app/grid/bin/crsctl start resource ora.asm - init
    Beginning of the resource ' ora.asm - init ' failed
    Could not start ASM
    The Oracle Clusterware boot failure battery
    [grid root@rac2] #.



    As seen above, the output at the end of the exit
    (1) beginning of resource ora.asm - init failed
    (2) could start ASM
    (3) could start Oracle Clusterware battery

    The runInstaller is in the first VM rac1. My question is:

    Any folk that understand how to solve the root.sh script in problem rac2 (3 fails to ora.asm, ASM and Clusterware battery as stated above)?


    Thank you.

    Please check there is no firewall don't exist:

    Try this as:
    root.sh fails on the second node

    Note MOS:

    Grid 11 GR 2: root.sh fails to start the Clusterware on the second node due to the firewall on the private network [981357.1 ID]

    Infrastructure 11.2.0.2 grid or upgrade installation may fail because of the requirement of multicast [1212703.1 ID] (most probabily this problem)

  • Someone called to try to resolve the problems and sell you something costs $173?

    Someone is the call of the India and say they represent Microsoft and scan your computer and then try to sell something to prevent future problems for $173?

    Fake phone calls to technical support

    Calls unrequested telephone of this nature are almost always a common scam. Do not let them give any info, do not give access to your PC, not give them all the money and do not go to all the websites that they suggest. One moment.

    Please see:

    http://www.microsoft.com/en-gb/security/online-privacy/msname.aspx .

    Microsoft issues never not solicited for phone calls of support or security.

    These types of callers can use completely fictitious names or bogusly claim to be of real companies other than Microsoft as well.

  • Yet to try to solve the problems with incorrectly platforms AUTODÉCOUVERTS

    Hello

    I have several platforms of AUTODECOUVERTS who are orphaned because I changed the IP address of the platform and the HQ 3.2.5 autodiscovery process that screwed up. I just upgraded to 3.2.6, which should prevent this problem in the future, but what I do now with five platforms that are sitting in my portlet "automatic detection" and won't go away?

    This prevents me to collect statistics on these platforms, because if I start an agent on one of these platforms, and then I try to import it, I get the error (in 3.2.6) below:

    Impossible to import the platform: java.rmi.ServerException: RuntimeException. nested exception is: org.hyperic.hq.common.SystemException: javax.ejb.TransactionRolledbackLocalException: a different object with the same identifier value was already associated with the session: [double found platform name: oms09 #10074]; CausedByException is: a different object with the same identifier value was already associated with the session: [double found platform name: oms09 #10074]

    How to remove these incorrect AUTODECOUVERTS platforms? They exist in a table somewhere that I can go in and just delete the right line?

    Thank you
    Brian

    These statements should fix you up:

    DELETE FROM EAM_AIQ_IP;
    DELETE FROM EAM_AIQ_SERVICE;
    DELETE FROM EAM_AIQ_SERVER;
    DELETE FROM EAM_AIQ_PLATFORM;

    (capitalization of the tables will depend on your database)

    These statements will erase all currently visible in the Portlet for Autodiscover.

    I hope this helps.

  • Do not understand the problem with My SQL...

    Greetings! Having a bit of a weird problem here...

    We update a Web site that uses forms and a database, and we did this once a year for the last 3 years. The man who worked on this subject before me created the elaborate together thing and then it died while he has put us in an awkward position... In any case... We have this form of quotation, and when the people, fill it out and click on submit, the information is sent to us and we fill then his quote based on the information the customer provides and then send us the quotation to the email they provided in the form. All this is done to a "base". OK so now when I fill out the quote form myself as a test and clicking on send, it says this...

    Warning : mysql_connect() [Function.mysql - connect]: Unknown MySQL server host 'duser1.db.7927716.hostedresource.com' (0) by /home/content/76/12767976/HTML/backend/configHR.php online 7
    can't do




    So by the looks of it, something is wrong in MySQL, am I right? It's something that I know much, but something is not communicate it would seem. He has never done this before.


    In case you wanted to know what it says in 'configHR.php, it contains these lines of code... ".


    <? PHP

    $host = "duser1.db.7927716.hostedresource.com";

    $username = "duser1";

    $pass = "Dosaur1";

    $database = "duser1";

    mysql_connect ($Host, $username, $Pass) or die ("cannot do '");

    @mysql_select_db ($Database);

    ? >

    I changed the names a little bit, so I don't understand our account...

    Now, it is important to point out that it recently had to change the user name ftp and password with GoDaddy to make changes to this website via Dreamweaver this year. Don't ask me why, they just made to us, and once we reconnect to the site with the new user name and password, this problem started occurring.

    So, what do you think?

    Thank you very much.

    Seems to me that there is a problem with your connection to the MySql database.  If the former web developer used old fashioned MySql connections and your server has been recently upgraded to PHP 5.5, which could explain the gap because the MySql connections are no longer supported in PHP 5.5 +.  To confirm this yourself, create a new page test.php with the following code and download on your remote server.  Then view the results in your browser

    phpinfo();
    ?>

    Nancy O.

  • Please help me understand the problem installing Acrobat Standard Xl with C++?

    I have an error message: "Visual C ++ 2010 (x 64) Runtime missing: Insralling Acrobat via MSI will not install Microsoft Visual C++ 2010 (x 64) SP1 runtime." With this, some features of the application will not work. You can try to install using set.exe if not already done. Press OK to ignore and continue nevertheless or Cancel to stop the installation. »

    I went to the Adobe help page on this topic. I tried to install the Microsoft C++ via the link, and a message simply offers a repair, which I chose. That made no difference - same error message when I try to install Acrobat.

    I do not understand because I see that I tried indeed to install using setup.exe - according to the directives of the disc. I couldn't find the vc - red.msi in VC10RT_x64 to re - install...

    Can someone help me with what to do else? I'm not an irritable person, just someone trying to do things...

    Put the CD and cancel the automatic installer.

    Use Windows Explorer to examine the contents of the CD, find the Setup.exe and then run that. I don't know if that will fix it, but that's my point of view on what the message says.

  • Try to understand the meaning of the attribute 3rd in this line

    Hello

    I'm trying to understand some AS3 code. I have a file using a

    Import fl.transitions.Tween;

    Import fl.transitions.TweenEvent;

    the line of code that I am trying to figure in the script is the following:


    var fadeTween:Tween = new Tween (None.easeOut, 0, 100, 30, fadeMeIn, "alpha", true);

    I know everything but the 30... In another line of code, I have for a moving image, that the value represents seconds on frameworks vs timeline because of the following true statement.

    Is this also what represents this 30... I'm not really able to say?

    Thank you

    Babs

    This is the time setting.  It is in seconds (if the 4th parameter is true), or in settings (if the 4th parameter is false or unspecified).

    interpolation of you has a duration of 30 seconds.

  • Confused.  Try to understand the Photo app Syncing iCloud

    Hi, just bought myself an old 5s iPhone which is big for me.

    I have some questions on how the Photos sync app works on my Mac.  I have a Mac mini desktop computer.

    This sharing of photos is incredible, but I am very new to it and get confused what is actually happening.

    I activated the option "Upload automatically to iCloud" on my iPhone but when I look on my desktop Mac that I do not see my most recent photos appear in the folder called 'iPhone' in my desktop version of Photos.  To get my downloaded photos I must actively download them from my phone.

    This folder has appeared after I connected my iPhone to my Mac via the USB cable.  I did this because someone on Facebook said.  This iTunes open for some reason and other things started happening that I don't understand.  I wanted to share pictures, not tunes and he tried to update but the Wi - fi wasn't working at the time so he kept failing.  When I checked the Wi - Fi works on my phone, it updated but iTunes kept trying to update.  Then the iPhone suddenly had all the records that I had done in Photos on my Mac, but the records were all empty.  Yet, all the Photos I had taken on my iPhone that day appeared on my Mac.  Now finally some pictures randomly my Mac on my iPhone as well and I do not understand why.  Then, when I open Facebook on my iPhone, the pictures that I had taken to a family visit appeared there with a musical slideshow!  What is everything?

    How does this work?  It works by sending photos of the invisible iCloud, which means that it requires action by me to make them appear in my desktop?  In this case, this mean I'll have hundreds, maybe thousands of images are circulating in the iCloud I can forget and end up running out of space on my iCloud?  Or do they stay on my phone until I have actively download them on my Mac?  If I turn off the automatic function, will I still be able to send photos to my Mac?

    If I delete a photo on my Mac, it will also disappear from my iPhone (and vice versa)?

    I have a lot of other questions but my poor old brain melting now and I forgot what I was going to ask, so I'll post them later.

    Thank you for your patience.  I'm old (and a bit thick).

    The IVous article explains works iCloud photo library.

    Photfos user / help guide:

    https://help.Apple.com/photos/Mac/1.0/?lang=en

    IVous has a very detailed and well illustrated article on iCloud photo library:

    http://www.IMore.com/how-use-icloud-photo-library-ultimate-guide

  • Try to understand the pricing and conditions

    Hello. I have read the terms, but nothing quite answered my question. As far as I understand, if my company purchases a month of service, downloads of our images of 50 allocated during the month, then stops and continues to use these images, it's ok, Yes?  Rather than continue to pay monthly for 50 images, we continue to use?  We will use them for the demo version of our software. They will never be sold off tension or something like that. We just wanted to buy the images that we must make our good demo look. Let me know.

    There is no 50 images a month plan. But once the image is licensed, you can continue to use it as long as you want as long as it's still in license restrictions, that it was purchased.

  • Try to understand the error of the changing table

    Hi all
    The error I get triggered only when only the table in question is updated? How bout when he got inserted or deleted?
    Assume that the following code creates TRGGER and runs the UPDATE and INSERT statements:
    CREATE OR REPLACE TRIGGER section_biu
    BEFORE INSERT OR UPDATE ON section
    FOR EACH ROW
    DECLARE
    v_total NUMBER;
    v_name VARCHAR2(30);
    
    BEGIN
      SELECT COUNT(*) INTO v_total FROM section WHERE instructor_id = :NEW.instructor_id;
    
      IF v_total >= 10 THEN
        SELECT first_name||' '||last_name INTO v_name FROM instructor WHERE instructor_id = :NEW.instructor_id;
        RAISE_APPLICATION_ERROR(-20000, 'Instructor, '||v_name||', is overbooked');
      END IF;
    
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RAISE_APPLICATION_ERROR(-20001, 'This is not a valid instructor');
    END;
    
    Trigger created.
    
    SQL> update section set instructor_id=101 where section_id=80;
    update section set instructor_id=101 where section_id=80
           *
    ERROR at line 1:
    ORA-04091: table STUDENT.SECTION is mutating, trigger/function may not see it
    ORA-06512: at "STUDENT.SECTION_BIU", line 6
    ORA-04088: error during execution of trigger 'STUDENT.SECTION_BIU'
    
    SQL> insert into section (section_id,course_no,section_no,instructor_id,created_by,created_date,modified_by,modified_date) values (200,10,1,108,user,sysdate,user,sysdate); 
    
    1 row created.
    The mutation of error raised when I tried to update the table but does not when a row is inserted.

    Is it possible to trigger the transfer error in running the INSERT statement without changing the trigger? Are there any other conditions that may trigger the error even without changing the trigger?

    Best regards
    TA.

    Published by: debonair Valerie on May 5, 2011 02:17

    The insert is a single row insert, and the database knows - it wiill do not suffer from any problem of changing table.
    However, update may or may not be dealing with many lines, so could have the question.
    If you did a multi line insertion, or even one that could potentially be multi line, then you get the same error.

    Carl

  • Catalyst Control Center has stoped working windows will try to solve the problem...

    I was just turning on my computer a couple of months and it poped upward, so its been like that for months... no flow back from the center of the action, I uninstalled the CCC and the ATI and I'm wut asked me to do it now, I still have the driver, I had to take it out or something (I do not know (, I am not a computer wizz), is there a link that can provide a solution for ATI Mobility Radeon HD 4330, I noticed a decrease in my grapics games now, such as the edges are rough and not smooth as if they were before, something was happening to my card to make it to go wrong, I'm just askn if theres a reason any I'm now :( I've been dying to get/game Nba 2 k 10 for PC, but I'm discouraged because of my card error, is there a link for me to download the same version or driver to get it operational?

    Oh and it's Windows 7 Home premium 64-bit

    For any question on Windows 7:

    http://social.answers.Microsoft.com/forums/en-us/category/Windows7

    Link above is Windows 7 Forum for questions on Windows 7.

    Windows 7 questions should be directed to / stationed there.

    You are in the Vista Forums.

    See you soon.

    Mick Murphy - Microsoft partner

  • Do not understand the problem of marked yellow Cotroller SM Bus... Why his yellow marked

    Here is the entire page driver for Windows 7 64-bit:

    http://h20000.www2.HP.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=5086734&prodTypeId=321957&prodSeriesId=5086733&swLang=13&TaskID=135&swEnvOID=4060#11394

    I'd install the Intel Chipset and video drivers. There is also a very recent BIOS update you can consider installing.

    If you need assistance.

  • Try to understand the build process phonegap

    I am trying to build an APK. Last night, I imported the zip file and corrected the errors. I intend only to build an APK then I don't insert the iOS/windows keys. I tried to wait until the end of the process, but it was late and I let him. Today, when I opened the project, the button of iOS has been shown as red and the Android (build bar?) continues to loading/building indefinitely. Is this good?

    Screen Shot 2016-04-01 at 07.36.16.png

    Edited: I removed the app created one other. Now I get: Upload error: Malformed Config.xml

    It happened after I get the splash screen / icons / cordova plugin game information:

    < src = "icon36.png icon" gap: platform = gap: qualifier 'android' = "ldpi" / > "

    < src = "icon48.png icon" gap: platform = gap: qualifier "android" = "mdpi" / > "

    < src = "icon72.png icon" gap: platform = gap: qualifier 'android' = "hdpi" / > "

    < src = "icon96.png icon" gap: platform = gap: qualifier 'android' = "xhdpi" / > "

    < src = "' splash_426x320.png gap: splash" gap: platform = gap: qualifier 'android' = "ldpi" / > "

    < src = "' splash_470x320.png gap: splash" gap: platform = gap: qualifier "android" = "mdpi" / > "

    < src = "' splash_640x480.png gap: splash" gap: platform = gap: qualifier 'android' = "hdpi" / > "

    < src = "' splash_960x720.png gap: splash" gap: platform = gap: qualifier 'android' = "xhdpi" / > "


    < name of the ditch: plugin = 'cordova-plugin-play' source 'MNP' = >

    < param name = "APP_ID" value = "XXXXXXXXXXXX" / >

    < / gap: plugin >


    I have found no reference on how to include these plugins:

    cordova-plugin-inappbrowser

    cordova-plugin-splashscreen

    cordova-plugin-device


    I think this way, but I do not know:


    "< name of the ditch: plugin ="cordova-plugin-inappbrowser"source ="MNP"/ >"

    " < name of the ditch: plugin ="cordova-plugin-splashscreen "source ="MNP"/ > "

    " < name of the ditch: plugin ="cordova-plugin-device "source ="MNP"/ > "


    Someone can it confirm?


    One more doubt: Phonegap for office does everything this Phonegap Build doesn't?


    Thanks in advance.



    You have a mistake here:

      
    

    You cannot use '-variable "like that in an XML file. See GitHub - cranberrygame/cordova-plugin-game: for use with PG, build. Although it uses the old syntax, then you would end up with something like this instead:

    
        
    
    

    Of course, you have all this in a comment ( ), XML is picky but you can not '-' in a comment string (because it could indicate the end of a comment).

    Furthermore, I would say switching to the modern config.xml file syntax to build of PG. See the docs:

    If you want to validate yourself, you can use an online service, such as http://www.xmlvalidation.com/ or XML Validator - powered by Validome.

Maybe you are looking for