Find everyday odd or a string in the Notes field.

In our environment, we are looking for a way to make sure some VMS are on the correct storage node.  I've got code working now, but like all things, I would like to make it that much better.

Most of the time, we want our odd number VMs to stay on our 'A-Side' storage and our even number VMs to stay on storage of 'b-side '.  A virtual machine is even or odd by the number given in the Notes field.

For example Notes for would look like this for a SINGLE virtual machine.  "Prod - payments - TC #02 ticket.

It is the line that I am looking to clean.

$VMs = get-data center < Center >. Get-DatastoreCluster | where {$_.} Name.Contains('-A-Side')} | Get - VM | where {$_.} Notes.Contains ('2') - or $_. Notes.Contains('#4') - or $_. Notes.Contains('#6') - or $_. Notes.Contains('#8') - or $_. Notes.Contains('#10') - or $_. Notes.Contains('#12') - or $_. Notes.Contains('#14') - or $_. Notes.Contains('#16') - or $_. Notes.Contains('#18') - or $_. Notes.Contains('#20') - or $_. Notes.Contains('#22') - or $_. Notes.Contains('#24') - or $_. Notes.Contains('#26') - or $_. Notes.Contains('#04') - or $_. Notes.Contains('#06') - or $_. Notes.Contains ('#08')} | Select Name, Notes

Yes, this is WAAAAY too long, but it do the job.  I also have a space after '#2' to make sure that it isn't catching #20 virtual machines etc..

Now, I know you can use %2 - eq 0 to find the odd or even days, but I don't know how to look at the field notes of powershell, remove the #XX and then check whether it is even or odd.

Ideas?

Try with a RegEx expression and the modulo function.

Something like that

$VMs = get-datacenter  |     Get-DatastoreCluster |     where {$_.Name.Contains('-A-Side')} |     Get-VM |     where {([regex]::Match($_.Notes,"#(\d*)").Groups[1].Value % 2) -eq 0) |    Select Name, Notes

Tags: VMware

Similar Questions

  • BlackBerry smartphone data truncated during synchronization - the note field size can be increased?

    I find that some data is truncated on the "BOLD" when my "BOLD" with Outlook synchronization. This is a problem for some of my bigger contact and entries of calendar notes.

    Is it possible to increase the size of these fields on the device must match which allows Outlook (or at all)?

    ... Thank you!

    It turned out that only some 200 entries truncated calendar had an atttachment, but some appeared to have a symbol (small rectangle) character that seems to replace a in the subject line. In my opinion, that they were introduced during a synchronized using an earlier version of Desktop Manager when I was with a Blackberry 8700.

    Re: problem of truncation: when syncing with the "BOLD", I discovered that in each case that a few words at most have been lost from the entries, regardless of the initial term. When I took the time to check them individually, most were not serious for me.

    Then... I still don't understand why it happened, but I was able to fix the problem for now.

    urumilton, thanks for your suggestion-

    rickn

  • Pull on the Notes field

    What would be the best way to shoot just a single word of the section notes.

    Assuming that there are a lot of things in the section notes and I wanted to just get out if he says 'Production '.

    Notes:

    Windows XP

    ABC rental

    Date: 090909

    Owner: scoobydoo

    Status: Production

    I want only the word 'Production' that I can send to another exit.

    I tried split and select-object but I am not having too much luck.

    Something like this should do the trick

    $mask = [regex]"(?Production|QA|Test|Dev)"
    $result = $vm.notes | Select-String -Pattern $mask
    $reportedvm.PatchSched = $result.Matches[0].Groups["status"].Value
    
  • pulling the Notes field

    Excuse the greenery in my powercli skills so I'm not even sure, is that I can explain what I'm missing so I'll give you an example of what I'm looking for

    I would like to shoot the "field notes" - If POSSIBLE like this

    $vms = "" | Select-Object VMName, OS, (Notes

    $vms. VMName = $vm. Name
    $vms. OS = $vm. Config.GuestFullName

    $vms. Notes =?

    but I do not know what to ask that by querying for the vmname ($vm. Name)

    Or am I just WAYYYYY in left field and not even on the right track?

    Thus, one, I can do it and I have question with

    two, is there an easy way for a dummy like me to know what I mark from virtual machines... I would like to collect information so I don't know that I have the same question about something else.

    Thank you!!!

    Drivera, you do it very well! No need to be frustrated

    Let me know what is not clear, because I see only the "main" question In regards to IP addresses, you can check how I did in some post me

    http://psvmware.WordPress.com/2012/10/24/report-for-all-VMs-regarding-network-card-MACAddress-IPAddress-network-card-type-e1000vmxnet-in-a-CSV/

    You can test this part of the code that describes the intellectual property and put to yourscript.

    Let me know if you have any other questions.

    I used this code and it works, ip is pressed:

    $Report = @)

    {foreach ($vm in get - vm)

    $vms = "" | Select-Object VMName, Notes, Hostname, IPAddress
    $vms. VMName = $vm. Name
    $vms. Host name = $vm.guest.hostname
    $vms. Notes = $vm.notes
    $vms. IPAddress = $vm.guest.ipAddress

    $Report += $vms
    }

    PowerCLI C:\ > $report | Select vmname, ipaddress

    VMName IPAddress
    ------                                  ---------
    testVM1 {192.168.0.9
    testvm4                          {}
    testx                               {}
    vmtest1 {192.168.0.4, fe80..:}

    It's just that the IP address can have several elements, when it has, it becomes an object array. So what to do

    .IPAddress $report [3] is an array that keeps 2 ips, 1 ip which is ipv4, and then which is ipv6.

    So basically to get first this virtual machine ip address you must use:

    $report [3] .ipaddress [0]-> this will be ip ipv4

    .IPAddress $report [3] [1]-> it will be the second ip address which is in this case some ipv6.

    IF you don't want to have ipv6 included ips you can filter

    $Report = @)

    foreach ($vm to {$x [0.10])}

    $vms = "" | Select-Object VMName, Notes, Hostname, IPAddress
    $vms. VMName = $vm. Name
    $vms. Host name = $vm.guest.hostname
    $vms. Notes = $vm.notes
    $vms. IPAddress = $vm.guest.ipAddress |? {$_ - like "*."} * "}-> This will make ipv6 went as they have: instead of."

    $Report += $vms
    }

    Let me know what does not work for you with these ips.

    Greg

  • try to find how to add timestamp to the notes I put in the section notes to contacts

    try to find how to add a timestamp to the notes I put in the section notes to a contact

    Hello jlaneco,

    Thank you for visiting the Microsoft answers community. The question you have posted is related to Office Outlook and would be better suited to the Community Office Outlook. Please visit the link below to find a community that will provide the support you want.

    http://www.Microsoft.com/Office/Community/en-us/default.mspx?DG=Microsoft.public.Office.misc&lang=en&CR=us

    I myself have sought a solution to this problem and have not found one solution viable, other than having to click Date & time whenever you want to place a stamp in your notes.

    Hope this helps

    Chris.H
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Where to find the Notes of the PES in Lightroom?

    Until recently, I used Photoshop elements (PSE) to scan family photos and save them as TIFF. All the information that I found the hand on the back of the photos, I copied in the 'Notes' 'Properties - general' field of the PES. I did some tests and confirmed that this information is written to the file.

    Now, I use Lightroom - and very happy with it - but I can't find those Notes in the same files. I looked everywhere in the metadata, but just can't find them.

    I guess that the information added to the post-secondary studies should be visible in Lightroom, so no idea on where they could be?

    Thanks for your help!

    tuspor wrote:

    Hello

    Thanks a lot to you both for your help on this!

    For now, I have about 600 TIFF in my PSE catalog. Maybe a third party data are entered in the field "Notes" of PSE7. Basically, as I understand it, what I do is transfer these information in the 'Notes' field to another field of PES that can be 'seen' by LR (perhaps "Caption"?).

    When I'm back home, I'll send a message with one of my attached files, so that you can see where the data is.

    I had a look at Exiftool, but I'm not sure that I am able to work with guests from orders. And in the standard, it is unclear if it can do what I want.

    You could manually transfer all PSE notes on legend.

    You can use SQLite to achieve this. (PSE7 catalogue is a SQLite database)

    You can certainly use ExifTool to do that as well.

    And, of course, you might be able to find someone who can do these things.

    These are your choices, I can say.

  • Change the Notes to custom for guests attributes field

    People,

    I need a way via Powershell (I know I could probably do via SQL, but I would avoid editing the VC DB directly) to go through a server cluster and be able to edit any guest VM that has a custom attribute defined in the Notes field. Our problem is that we use Platespin for all of our P2V and he puts this long text string after each conversion in the Notes field:

    "Virtual Machine created by PowerConvert 7.0.0.5157 08/08/2008 23:47:46.

    We want to shorten the chain to a something simple, since it appears on reports and causes problems with the formatting, something like "P2V 08/08/2008 23:47:46.

    Anyone have any ideas?

    Thank you.

    You can use the - operator replace like this

    $text = "Virtual Machine created by PowerConvert 7.0.0.5157 on 8/8/2008 11:47:46 PM"
    $pattern = "Virtual Machine created by PowerConvert 7.0.0.5157"
    $newtext = $text -replace $pattern, "P2V"
    $newtext
    

    If the model is not constant, then we use a regular expression for the matching process.

  • Smartphones blackBerry how to enter text in the 'notes' fleld in my contacts?

    I need to keep various information with my contacts (directions to locations, password tips, etc.).  When I scroll to the bottom of the screen to enter new contact at the end it says that there is a field for notes, but when I try to enter, pressing the trackball or press the blackberry key to bring up a context menu, I get the following options:

    Save

    Add custom ringtone

    Add photo

    Help!

    Move the note field and simply enter the text, you don't need to click on anything whatsoever.

  • Organizer of PES, 13, is the field "notes" a real field of IPTC data or a data only to the organizer field?

    I would like to access the 'notes' field in several files and write to it.  Is this possible?  If Yes, where is the 'notes' field in the METADATA information?

    It is only searchable/viewable in elements Organizer.

  • Look for the string of the numbered array element.

    This is my first post, so I'll probably miss one thing or another.  I will look nothing missed as soon as possible. I write code LV to test additional County stored in a CSV text file. Counties represent the stimulated current of a diode in a beam of radiation. The product is a QA device for a medical radiation treatment machine. The Integrator output proportional to the current diode accumulates as a whole into account in the text file. My LV code puts the numbers in the tables, calculates the incremental time derived and analyzed statistically. Numbers of the columns in the table data represent unique components. Default number of data column is sorted in a 1 d table has no column number. As if not column 10 represents CR39 of PCB 11. I need an algorithm how to connect a string such as CR39-PCB11 to the element of the array 1 d failure or relate to the string to the column in the data table that fails. Could you suggest a way to do this?

    If I understand you correctly, instead of these numbers that are in the Updates (odd) 'zero', you want to get premium channels. For the moment, the operator uses a lookup table, to find the chain (component) that corresponds to the column number.

    It's easy, because you only need an array of strings (corresponding to the column number 0 n) and use the array index with the index of the column. Place it in a loop for get all the clues of failures (the loop autoindexing for).

    Felix

  • Problem: Build a VI to display a string in the table of the lights. Each letter must be posted in a separate table and letters must move from one table to the other in the direction from left to right.

    Hi all

    Problem: Build a VI to display a string in the table of the lights. Each letter must be posted in a separate table and letters must move from one table to the other in the direction from left to right.

    I did program mentioned above but it does not work. Can you tell me what is the problem?

    There is no error is indicated in the program. If someone knows about it please try to find solutions and help me out of this problem.

    I have attached my program with this message.

    Thank you in advance!

    (1) FOR loops are your friend here.  You can make a slight restructuring using loops, and then you will have less mess to deal with, the inner loop through tunnels of autoindexing to make it even simpler.

    (2) I would only treat the numeric values of the characters.  So go terminal of control of the chain, the capital letters and byte array to before the outer loop.  You can use a size of Board over there to tell how many times the outer loop to iterate.

    (3) the Index table is extensible.  So you only need over the index of the first, and it will increment itself, as it develops.

    (4) you need to finish the lookup table (table 3D)

  • Incorporate the binary string in the string spreadsheet file

    Hello LabVIEW wizards...

    So I use scripture to VI file spreadsheet to create a beautiful layout, tabs-delimited report of one of my programs for the acquisition of data file. In one of the cells in the resulting worksheet file that I want to put a binary string of all my control values so when you open the data file all the control parameters used for its manufacture are restored, but the string is hidden when the report is displayed in Excel.

    The problem is that the binary string flattened uses tabs and returns as part of its syntax the Spreadsheet File this VI to Write it's going in all directions. Worse yet, I can't unflatten chain when I open the file text because of "corrupt data or unexpected".

    If I concatenate the string flattened with quotes around it she is superb and is placed in a single cell in Excel, but when I open the file in LabVIEW that she is still several elements in the array. I've isolated the binary string using the file VI text reading and got a subset of the quoted string, but it still unflatten correctly.

    Essentially, I need to know how to get LabVIEW to pull a string literal full of special characters into a spreadsheet file and it unflatten. Any gurus what help you can provide is greatly appreciated.

    Thank you

    Jordan

    Jordan

    I suggest that you change the formatting of your chain shipped by replacing the tabs and returns with other characters that are not considered as commands by the spreadsheet functions. Without knowing how you represent your control binary values, I can't offer specific characters.

    If two non-printable characters exist which do not appear in the control data, it's easy: just find and replace tabs and returns with those characters.  If there is no character, then something more complex needs to be done for example to escape special characters.  Or create two subVIs - one to remove the tabs and returns before writing the string in the file and the other to restore after reading.

    Lynn

  • Need to convert a local 'digital' to a type value string using the browser of the expression.

    I'm trying to convert a local "numeric value" to a string via the browser of the expression to provide a string argument.  I'm currently looking through the options of expression browser, but I can't find any type of function 'ToString()' Number.

    Hi you should try this:

    Str (people of the country. MyNumeric)

    Concerning

  • The search for exact strings (and the right formula)

    I am using FIND instruction to search multiple strings in a larger formula. The original formula that I do stand out is the following:

    = IF (ISNUMBER (FIND ('INC', A1)),' ', 'Y')

    Of course, this gives a Y if he finds some text in "". "" However, I have several channels for which I would check, and they need to be exact. That is to say when I search Inc. and Inc., I don't want Inc. to be counted. So, I tried the following formulas.

    = IF (ISNUMBER (FIND (OR("INC",inc"), A1)),' ', 'Y')

    = IF (SUM (COUNTIF (A1, "* INC. *","{* Inc. *}")),' ',' Y')

    The second works better, but it also counts Inc. as a football game. Any suggestions?

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • The analysis of string in the input channels

    Hello

    I'm trying to parse a string into a matrix, or tables in real time. Thus, assuming that the line below is part of my entry

    A134B932C321D95E532F1024A13B932C321D95E532F1024

    I would like to analyze the data and constantly create a matrix (or a series of paintings), such that each row corresponds to a letter. For example, something like below:

    13 13

    932 932

    321 321

    95 95

    532 532

    1024 1024

    I was able to parse the string using the letters as delimiters, but I was not able to find a way to organize the values. The goal of my project is to receive 6 different a mircoprocessor input and displaying the entries on different graphics.

    Thank you in advance,


Maybe you are looking for

  • I can't print a help me

    My printer does not print It's new and I made what they want me to I really need help If I got help I will be grateful http://im38.gulfup.com/gq82W.jpg http://im38.gulfup.com/v8zK4.jpg

  • How can I manipulate the memory of a BALL

    I want to use a CMOS PROM but I have the function locate can´t to handle this device in the memory display. The type of the PROM is 27 c 128 - 12 p. Thanks for the help

  • I tried to install windows 7 and he shot his request now a windows key

    original title: Windows Is it possible to recover my windows vista? I tried to install windows 7 and he shot his request now a windows key. any suggestions?

  • Windows Firewall starts do not

    Hi guys,. My Windows Firewall does not work correctly. When I try to boot in the center of the Action manually by the option "USE the SETTINGS RECOMMENDED", I get this error message. and also when I try to start 'CORE FILTERING ENGINE' in 'SERVICES',

  • Profile of lenses

    I have a new Fujifilm x - e2s with a kit lens. The camera and lens appear in the metadata, but I can't get the lens recognized automatically to the profile of corrections lenses lenses of the develop module I can't get it in manually.How can I get my