permissions / roles scripting help

Hi guys,.

I just recently discovered the beauty of the kit VI Toolkit and immediately felt it was necessary for this. I need a script to scroll through each VM in a given datacenter and assign a role existing a permission level on this virtual machine.

Hierarchy is as follows:

Datacenters\ & lt; Region & gt; ------& lt; Site & gt; ------& lt; VM name & gt;

or

Datacenters\ & lt; Region & gt; ------& lt; Site & gt; ------& lt; Folder & gt; ------& lt; VM name & gt;

I need the script to parse the name of the virtual machine, and then assign the VirtualMachineUser role to the Group of field domain\\user & lt; VM name & gt;. _Admins

Any help would be greatly appreciated!

Thank you!

Looks like this means to use a code level API to access the Manager.

http://communities.VMware.com/message/1076484#1076484

I adapted the code example is the post above and below the code, just worked in my lab, but please limit testing to a couple of servers before you set loose.

#pipe virtual machines to Get - view to get the .net objects representation

#you need for the MoRef required by the SetEntityPermission method

#recommend for tests that limit you to a specific set of virtual machines using Get-VM-name (list of names separated by commas)

$vms = get - VM | Get-View

#access authorization manager

$authMgr = get-View Manager

#use a filter against the Manager very well the role you want

$role = $authMgr.RoleList |? { $_. Name - eq "VirtualMachineAdministrator"}

foreach ($vm to $vms)

{

#create permissions

$perm = new-Object VMware.Vim.Permission

$perm.group = $false

$perm.principal = "Domain\\user"$vm. Name"_Admins".

$perm.principal

$perm.propagate = $false

$perm.roleId = $role. RoleId

#for each VM discovers, call the method to update the permissions

$authMgr.SetEntityPermissions($vm.) MoRef, $rootperm)

}

I hope this helps!

======================================

Monitor. To correlate. Act. | vWire.com

Tags: VMware

Similar Questions

  • Placeholder text replacement script help

    Hello expert AppleScript!

    I have a problem with the script to replace text placeholder from this source: https://iworkautomation.com/pages/script-tags-placeholder-text.html

    For testing purposes I just wrote a text on a white sheet (not insert a text box and the text typed there) and insert an image, a placeholder text marked (and a picture too) through the instrument standard Pages: Format-> advanced-> mark as placeholder text (image) (don't remember the exact wording)

    Then I executed the script but it worked only in part to replace the placeholder image but not the text.

    Is there an error in this script, or maybe I did something wrong?

    Thanks for the help in advance!

    5.6.2 pages

    OS X El Capitan v. 10.11.5

    Hello

    It's a bug when a placeholder is in the body of the text with one of the following conditions:

    No insertion point in the document.

    The insertion point is not in the body of the text (in an text box as example)

    Workaround:

    The script must create a new section in the document, place the insertion point in the body of the text

    ------

    Tell application "Pages".

    activate

    the value of thisDocument to make the new document with properties {model: "Journal Newsletter" template}

    According to thisDocument

    make new section - who put the insertion in the body of the text

    -MAKE ALL TAGS

    -do something with a space reserved

    tell the end

    --------

  • DDL script help

    Hi all

    We are in Oracle 11 g 2 in WIN 2008R2. I want to generate the DDL script for the user to XDX schema. User schema have the sequence type of the object, operator, procedure, package bodies, lob, package, library, type body, trigger, table, index, view, indextype, function and type. I like to shoot all the ddl for these objects to XDX in a script. Please let me know if that's ok. I appreciate your help.

    Go head

    trigger the echo

    set pagesize 0

    set verify off

    Set feedback off

    coil schema.out

    Select dbms_metadata.get_ddl (object_type, object_name, owner)

    Of

    (

    -Convert DBA_OBJECTS. OBJECT_TYPE type of DBMS_METADATA object:

    Select

    owner,

    object_name,

    decode (object_type,

    'EMPLOYMENT', 'PROCOBJ ',.

    'PACKAGE', 'PACKAGE_SPEC ',.

    'PACKAGE BODY', 'PACKAGE_BODY ',.

    'TYPE', 'TYPE_SPEC ',.

    'TYPE BODY', 'TYPE_BODY ',.

    object_type

    ) object_type

    from dba_objects

    where owner in ('XDX")

    -These items are included with other types of objects.

    and not object_type in ('PARTITION of INDEX', 'LOB', 'PARTITION LOB', 'PARTITION TABLE')

    -Ignore the types generated by the system that support the processing of collections.

    and not (object_type object_name like '% SYS_PLSQL_' and 'TYPE')

    )

    order by owner, object_name object_type

    /

    Export utility exp can do the same thing as 1 lining

    If above works for you, then you don't have any other approval

  • FDMEE Jython Script help

    My load the import data were thrown a curve ball. I used to have a 1 or 2 digits in the card. If it's a digit, I simply added a zero at the beginning (i.e. FillL convert 1 01). But now I have a leader 4 digits and a hyphen. So instead of '1', I have 2500-1, instead of "12", I now 2500-12. I need to remove what is to the right of the dash and then add a zero not significant if it is not already 2 digits. Does anyone know the script that would achieve this?

    Your help is very appreciated.

    FA

    Hello

    You can create this jython script and assign import format:

    def customFill (strField, strRecord):

    return ('0' + strField.split("-") [1]) [-2:]

    This function divides your strField using "-" as the delimiter, then him concatenate '0' with the second element ([1] in the table starts in position 0) and finally to take the last two characters [-2:]

    If you have 1 number after the hyphen you will get 0 x. On the other hand, if you have already a 2-digit, you will get xx

    Hope says.

  • Basic script help

    Hello world

    I haven't used PowerCLi before (but know previous script).

    I need to write a script that will tell me that VM have discs that are thin provisioned. Can anyone help?

    Thank you.

    David

    Try this

    It shows what vm and what the VM vmdk is thin

    http://www.vcritical.com/2009/01/finding-thin-provisioned-virtual-disks-with-PowerShell/

    
    $vmtp = Get-VM
    $vmtp += Get-Template
    
    foreach($vm in $vmtp | Get-View){
      foreach($dev in $vm.Config.Hardware.Device){
        if(($dev.GetType()).Name -eq "VirtualDisk"){
          if($dev.Backing.ThinProvisioned -eq $true) {
            $vm.Name + "`t" + $dev.Backing.FileName
          }
        }
      }
    }
    
  • SRM permissions & roles - should I really use them?

    If my AD account is already a member of the role of own vCenter who has administrative access to everything, do I need to bother with the roles of MRS.?

    I continue to re-read the manual and it is not clear to me.


    In my view, there are many roles, but he doesn't seem to be a role that provides all the SRM features in one fell swoop.


    See you soon

    Hello

    There are three things to understand here:

    (1) authorities in the SRM inventory. If you go to the screen of the SRM and look on the permissions tab, you can see that you can (and should) give permissions to be able to run SRM. Permissions can be granted on the associations for the Protection and recovery of Plans also. These permissions are separate from vCenter permissions.

    (2) vCenter permissions that are associated with SRM. To be able to configure the virtual computer protection, you must have Virtual Machine--> Configuration--> repeated privileges. May be granted at different levels in the vCenter inventory.

    (3) 'regular' vCenter permissions required to perform tasks SRM. You need various privileges, such as rescan HBAS, create / delete virtual machines, etc. in order to protect virtual machines and perform the failover / test. May be granted at different levels in the vCenter inventory.

    (About your specific case, you have the role of 'Administrator' to vCenter inventory, 2) and 3) are OK. 1), by default, only the Administrators Local Group is given 'Administrator' role to the SRM inventory (this role includes all permissions of MRS of course). Make sure you are a member of this group, or if you work with the domain group, grant needed the permissions of this group (s). I recommend you to give Run / Test permisiions to a group very small number of people, as the execution of these tasks has dramatic consequences on the environment.

    Michael.

  • Add Nas file systems in a script - Help!

    I have 15 ESXi servers and I need to add about 10 NFS Volumes per server.  There is 'NO WAY', I do it manually.  I know how to add a NAS store via the command-line of vMA.   I need help is adding in a script for all NFS connections.

    Can someone help me to start creating a script where I can add all the connections, so I don't have to add each volume manually?

    vicfg-nas - Server myesx - Host.com - add - nasserver my.netapp.com s/mount dir nfsstore.

    I add all of my NFS connections in a file/script so I can just run and all NFS volumes are mounted?

    Remember, I need an example if possible, I'm a little green on writing scripts for the vMA.

    Just try to make my life easier with the vMA and your assistance.  Thank you for your help in advance.

    If you take a look at the blog, they go on a few examples on how to use vi-fastpass.

    Here's another thread that may be useful - http://communities.vmware.com/message/1587207#1587207

  • If/then box script help in the form of Adobe Acrobat...

    If having a purchase order that has two different fields of price (regular price per point & subscription price per article for each line item, then a quantity) and then a total field. Finally, there is a checkbox on the form indicating if they sign up for a monthly subscription.

    What I try to do is create a script that totals each line by the current price multiplied by the quantity or the price of the subscription by amount if the subscription checkbox is checked ("Yes"). So far, I've tried several scripts, I found in the forum but no luck at all.

    The box is near the billing fields down, so all the line items first appear in the upper part of the form. Thus, an individual if each line and calculations would amount in total to each line (reg * qty price) when you get off of the form... When you check the subscription all line totals would have changed to reflect the subscription rates on each line (which may be different). Just need help with a single line and I can duplicate for each line...

    Here's what I does NOT again...:

     (function () {
    
    
    if (this.getField("sub").value==="Yes") {
         var b1 = this.getField("Price1b");
         var c1 = this.getField("Qty1");
         var d1 = this.getField("Price1");
         event.value = b1.value * c1.value;
    } else event.value = d1.value * c1.value;
        }
    
    
    )();
    
    

    Try this:

    (function () {}

    var b1 = getField("Price1b").value;

    var c1 = getField("Qty1").value;

    var d1 = getField("Price1").value;

    If (getField("sub").value = 'Yes') {}

    Event.Value = b1 * c1;

    } else {}

    Event.Value = d1 * c1;

    }

    })();

  • Java Script Help

    I have a table in a form with a text filed and a numeric field. I have the deposited text populated by a button.  (For instance I have fixed windows elements, tilt and turn Windows, beats Windows, project in windows, then I simple Outswing doors, Inswing French doors and so on.) I wish that when someone selects an element that was a door in the numeric field if the size is larger, then 108 "the user would have a popup saying you must have a smaller size 108"if they choose a list window, the popup say you must have a size of less than 80")

    Your help with this script would be greatly appreciated.

    Here's the corrected code that works if the field width output.

    var i = this.parent.index;

    If (xfa.resolveNode ("Table1.Row1 [" + i + "]").) Item.rawValue == "680 ch" & this.rawValue > 108) {}
    xfa.host.messageBox ("you must have a size of less than 108");
    xfa.host.setFocus ("Width");
    }

    Two things to fix.

    (1) in your code, you have special characters after 108 (double quotes. You could have copied and pasted. You can check the double quotes of beginning and end of double quotes are not the same.)

    (2) the line1 is attached to a dynamic section. So always check the current line get field values.

    Thank you

    Srini

  • Script help please. You will need to save it as a different file type.

    I have a script which now saves files as jpg files.  I need to save a png image.  Someone would be able to help me with this?

    var doc = app.activeDocument;

    var Path = doc.path;

    var Name = doc.name.replace (/ \.) [ ^\.] +$/, ''); Var suffix = "_full_l"; var saveFile = file (path + "/" + "full_l" + ".jpg"); SaveJPEG (saveFile, 8);

    function SaveJPEG (saveFile, jpegQuality) {jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.embedColorProfile = true; jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; jpgSaveOptions.matte = MatteType.NONE; jpgSaveOptions.quality = jpegQuality; activeDocument.saveAs (saveFile, jpgSaveOptions, true, Extension.LOWERCASE) ;}}

    Here you are...

    var doc = app.activeDocument;
    var Path = doc.path;
    var Name = doc.name.replace(/\.[^\.]+$/, '');
    var Suffix = "_full_l";
    var saveFile = File(Path + "/" + "full_l" + ".png");
    SavePNG(saveFile);
    function SavePNG(saveFile){
        pngSaveOptions = new PNGSaveOptions();
        pngSaveOptions.embedColorProfile = true;
        pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
        pngSaveOptions.matte = MatteType.NONE;
        pngSaveOptions.quality = 1;
     pngSaveOptions.PNG8 = false;
        pngSaveOptions.transparency = true;
    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
    }
    
  • Date Validation Script Help

    Hello

    I have created a form of travel on designer adobe 7.0 for employees to fill before going on vacation.  So I wrote a script that makes sure the date entry for DateFrom is > = the current date and DateTo > = DateFrom.  I was told to do the date format MM/DD/YY, but for some reason any script works only when the format is DD/MM/YYYY.

    Here is my script for DateFrom:

    If (Date() < Date2Num ($.formattedValue, "MM/DD/YYYY"))

    then

    xfa.host.setFocus ("xfa.form.form1.DateTo")

    on the other

    xfa.host.setFocus ("xfa.form.form1.DateFrom")
    xfa.host.messageBox ("your requested date cannot come before the date of the day", "warning.", 1).

    endif

    and the script for DateTo:

    If (Date2Num ($.formattedValue, ' DD/MM/YYYY "" ") > = Date2Num (xfa.form.form1.DateFrom.formattedValue," MM/DD/YYYY ""))

    then

    xfa.host.setFocus ("xfa.form.form1.enterC")

    on the other

    xfa.host.messageBox ("the"TO"Date must come after"FROM"" Date, "TO DATE ERROR" ")
    xfa.host.setFocus ("xfa.form.form1.DateTo")

    endif

    enterC is the object of discussion after DateTo

    I tried what is obvious by the formattedValue of switching to "MM/DD/YY", but without success.  I also tried the model display, Model Validation, switching and model data to "MM/DD/YY", but nothing seems to work.  Does anyone know how to make this work with MM/DD/YY?

    Thanks in advance for any help

    Nick

    This is to separate the display format of the script format. You can use any format you like in the display format and will not interfere with the script. In the script I always like to use "YYYY-MM-DD" in international format that you don't have to worry as long as you set the display and change the formats you like.

  • Script Help: The names of layers from the Excel data

    Hello!

    I'm a noob script and have tried to learn, but unfortunately I just haven't the time. Projects at work keep me in the Bay. In any case, here's my scenario and I hope someone can guide me.

    I want a script that would look at a database (XML, CSV, excel or anything that works) and create separate layers in illustrator based on the data.

    Example: description and part number comes from a database. Name of the Illustrator layer is what I want the automation script. The reason for this request is a 200 point that I don't want to retype.

    Part numberDescriptionName of the Illustrator layer
    33456Point 133456_Item 1
    33457Point 233457_Item 2
    33458Point 333458_Item 3
    33459Point 433459_Item 4
    33460Point 533460_Item 5
    33461Item 633461_Item 6
    33462Point 733462_Item 7
    33463Item 833463_Item 8

    After that, I have all my items, with correct layer names, I export each layer as a separate PDF file. The name of the export file would be identical to the layer name with "_1up" appended to the end. For example, 33456_Item 1_1up.ai.

    I would have a separate illustrator file that contains all the same name of the layer as above and then I place the exported file, he respected the layer. This is where the script of another would be great. Is it possible to make a script that will place an image on a layer that has similar naming structures (the only differences would be the name of the layer would not "_1up")?

    I hope this makes sense and I know that I ask a lot. I thank very you much in advance!

    still not sure why export you all the layers to separate the files only to place them all back again?

    but this will get your layers created.

    var line,lay,myLayers = [];
    var csvFile = File('e:/csv.csv');
    csvFile.open( 'r' );
    while(!csvFile.eof){
        line = csvFile.readln();
        line = line.replace(',','_');
        myLayers.push(line);
    }
    csvFile.close();
    var doc = app.activeDocument;
    for(var i = myLayers.length - 1; i > 0; i--){
        lay = doc.layers.add();
        lay.name = myLayers[i];
    }
    var oldLayer = doc.layers.getByName('Layer 1');
    oldLayer.remove();
    

    CSV should simply be:

    33456, point 1

    33457, point 2

    ...

  • VM query script help

    I learned enough here to dial below scriptlet that will find VMs on specific data warehouses and port attached to some groups, but have been omitting hours trying to add another variable without leaving the loop and the re - scan all VM again.

    I need the command get - VM to include also the annotation get? | {$_. Value - eq "supported"} and also revisit the results for the output looks like:

    Annotation of data parent store

    VMname Datastore1 saved

    Get-cluster |? {$_. {Name - notlike ' * Lab * "} | Get-vmhost | Get-Datastore? | {$_. Name - notlike "* ISO *"- and $_. {Name - notlike "* models *"} | {ForEach-Object

    $ds = $_. Name

    $_ | Get - VM | Get-NetworkAdapter |? {$.NetworkName - like "Network backup" _} | {Select-Object Parent,@{n='DataStore'; e = {$ds}}

    }

    any help would be appreciated.

    Try something like this

    foreach($ds in (Get-Cluster |                 where($_.Name -notlike "*lab*"} |                Get-VMHost | Get-Datastore |                 where {$_.Name -notlike "*ISO*" -and $_.Name -notlike "*templates*"})){  Get-VM -Datastore $ds |   where {(Get-NetworkAdapter -VM $_ | Select -ExpandProperty NetworkName) -ne "Backup Network"}  Select Name,    @{N="Datastore";E={$ds.Name}},    @{N="BackedUp";E={Get-Annotation -Entity $_ -Name "NameOfTheAttribute" | Select -ExpandProperty Value}}}
    

    You must use the custom attribute appropriate in place of the "NameOfTheAttribute" name, I used

  • Powercli Script Help of misalignment VMDK

    I have a script that I run against a vCenter server. Basically, find all the VMS in vCenter and ruins a command get-wmiobject against them to get the VMNAME, Partition, Offset and status, as well as exports in excel.

    Here is an example of output data that gets exported to excel:

    VMNamePartitionOffsetStatus
    pdxvvmdb1Disk #0 Partition #18193150 KBPartition NOT aligned
    pdxvvmdb1Disk #0 Partition #18193150 KBPartition NOT aligned

    My "problem" is its does not give me the right excel (via information system) partition info, see below.

    He has only 1 vmdk with 2 partitions, so it should output the two partition 1 and 2 and offsets, since they are both incorrect?

    In the research to add a line to the script to add the data store and the location of the vmdk (pdxvvmdb1/pdxvvmdb1.vmdk [PDXESX1_RAID]) file in this case and have the excel output. Possible?

    I have attached the script from his long enough...

    I made the same mistake you did at the beginning, the $Details object must be created at the lowest level.

    Like this

    # Add-PSSnapin vmware.vimautomation.core
    connect-viserver vspheredev
    $myCol = @()
    $mycol.Initialize()
    $vms = get-vm | where {$_.PowerState -eq "PoweredOn" -and $_.Guest.OSFullName -match "Microsoft Windows*" } | Sort Name
    foreach($vm in $vms)
    {
        Try
        {
            $wmi = get-wmiobject -class "Win32_DiskPartition" -namespace "root\CIMV2" -ComputerName $vm -ErrorAction silentlycontinue
            foreach ($objItem in $wmi)
            {
                if ($objItem.StartingOffset % 64kb -eq 0){
                    $Details = "" | Select-Object VMName, Partition, Offset, Status, VMDKPath                $Details.VMName = $vm.name                $details.VMDKPath = $vm.HardDisks[0].Filename                $Details.Partition = $objItem.Name                $details.offset = "$([long]$($objitem.StartingOffset)/1KB)KB"                $Details.Status = "Partition aligned"
                }
                else            {
                    $Details = "" | Select-Object VMName, Partition, Offset, Status, VMDKPath                $Details.VMName = $vm.name                $details.VMDKPath = $vm.HardDisks[0].Filename                $Details.Partition = $objItem.Name                $details.offset = "$([long]$($objitem.StartingOffset)/1KB)KB"                $Details.Status = "Partition NOT aligned"
                }
                $myCol += $Details        }
       }
       catch
       {
            $Details = "" | Select-Object VMName, Partition, Offset, Status, VMDKPath        $Details.VMName = $vm.name        $details.VMDKPath = ""        $Details.Partition = "error"        $details.offset = ""        $Details.Status = "error"        $myCol += $Details    }
    
    }
    $mycol  | Export-Csv -NoTypeInformation "H:\Excel_Reports\NEW_Production_PartitionAlignment.csv" #output errors to file
    $error >>  "c:\temp\partition-check-errors.txt"
    $error.clear()
    

    Note that in the property VMDKPath the script stores the path of the 1st VMDK.

  • Custom calculation script % help

    What is the custom calculation script to arrive at a percentage of penetration between two fields? Example: 50 / 100 = 50%

    The simple notation of field: field 1 / field 2

    Custom script:

    var v1 = + this.getField ("Field 1") .value;

    var v2 = + this.getField ("Field 2") .value;

    If (v2 == 0) event.value = "";

    else event.value = (v1 / v2);

Maybe you are looking for

  • How to move pictures on film?

    I noticed that when I try to organize my collection of pictures and to place images in different albums, they do not move out of my camera roll, but they are copied into the selected album. I want to move those pictures, not to copy them, how does th

  • printer problems with the new version of el capitan

    Since I've updated, I can't print!

  • Getting IP address conflict

    Hi allRecently we are facing a strange problem, we have about 5 windows server 2003 and about 50 users windows xp SP3 all our servers get IP address conflict error at the same time, and we need to disable and enable the network card, sometimes even n

  • Installation of Windows 7 ultimate 64 bit on DV6 2165TX

    Hello I had posted earlier on the unused hardware reserved RAM when I upgraded my RAM to 3 GB, 6 GB. Link pasted below http://h30434.www3.HP.com/T5/hardware-upgrades-replacements/HP-Pavilion-DV6-2165tx-3GB-hardware-RESE... I have suggested that I ins

  • When Auto update the tracks it still fails Error 1402 code 0X57A

    How automatic update works always fails to update Microsoft Office 2003 SP (Service Pack) 3. I get a 0X57A error message. Anyboby e els I have this problem?