Script to configure security on vSwitch error

Here's my problem. I set up a script to configure ESXi 4 U1 guests. During the configuration, we must define security vSwitch reject for allowPromiscuous, forgedTransmits and macChanges. Here is the section and the error.

$vh01 = get-vmhost myhost.domain.com

$vh01vsw0 = $vh01 | get-virtualswitch-name "vSwitch2.

$vh01moref = $vh01 | % {get-view $_.} ID}

$vh01morefconfig = $vh01moref.configmanager

$vh01netsys = $vh01morefconfig.networksystem

$vh01netsysmoref = get-views $vh01netsys

$swspec = new-Object Vmware.Vim.HostVirtualSwitchSpec

$swspec. NumPorts = 24

$swspec.policy = new-Object Vmware.Vim.HostNetworkPolicy

$swspec.policy.security = New-Object Vmware.Vim.HostNetworkSecurityPolicy

$swspec.policy.security.allowPromiscuous = $false

$swspec.policy.security.forgedTransmits = $false

$swspec.policy.security.macChanges = $false

$vh01netsysmoref. UpdateVirtualSwitch($vh01vsw0.name,$swspec)

And the error I get is:

Exception by calling 'UpdateVirtualSwitch' with '2' or argument: 'a specified perréard.

TER was not correct.

"

TO C:\ Docs\PowershellScripts\StateConfigScripts\switchsec_test.ps1:17 char: 3

7

+ $vh01netsysmoref. UpdateVirtualSwitch < < < < ($vh01vsw0.name, $swspec)

+ CategoryInfo: NotSpecified: ( [], MethodInvocationException)

+ FullyQualifiedErrorId: DotNetMethodException

If I run $vh01vsw0.name I get the string correct vSwitch spokesperson. I have a script section to set the same on trade, and it works fine. Here's the script section.

$vh01 = get-vmhost myhost.domain.com

$vh01moref = $vh01 | % {get-view $_.} ID}

$vh01morefconfig = $vh01moref.configmanager

$vh01netsys = $vh01morefconfig.networksystem

$vh01netsysmoref = get-views $vh01netsys

$pgspec = new-Object Vmware.vim.HostPortGroupSpec

$pgspec.vswitchname = "vSwitch0"

network of $pgspec.name = "Management"

$pgspec.vlanid = "0"

$pgspec.policy = New-Object Vmware.Vim.HostnetworkPolicy

$pgspec.policy.security = New-Object Vmware.Vim.HostNetworkSecurityPolicy

$pgspec.policy.security.allowPromiscuous = $false

$pgspec.policy.security.forgedTransmits = $false

$pgspec.policy.security.macChanges = $false

$vh01netsysmoref. UpdatePortgroup($pgspec.name,$pgspec)

Is this something that needs to be done when creating vSwitch and cannot be changed after? Any help is greatly apprecieated! Thanks in advance!

No, it can be done.

But since there is an existing switch, you can not 'Cancel' some properties that are already there.

Although the SDK Reference indicates that some properties are optional, when set on an existing vswitch, you must include them in the spec.

The easiest way is to copy the existing technical and only change the properties you want to change.

Something like that

$vh01=get-vmhost myhost.domain.com 

$vh01moref=$vh01 |% {get-view $_.Id}
$vh01morefconfig=$vh01moref.configmanager
$vh01netsys=$vh01morefconfig.networksystem
$vh01netsysmoref=get-view $vh01netsys
$vh01vsw0=$vh01netsysmoref.NetworkConfig.Vswitch | where {$_.Name -eq "vSwitch2"}

$swspec= $vh01vsw0.Spec   # here you copy the existing spec object

$swspec.policy.security.allowPromiscuous=$false
$swspec.policy.security.forgedTransmits=$false
$swspec.policy.security.macChanges=$false

$vh01netsysmoref.UpdateVirtualSwitch($vh01vsw0.name,$swspec)

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • I replace my airport express with the new model. Flashing orange. It works, but cannot configure security. Tried to reset via the reset button.

    I replace my airport express with the new model. Flashing orange. It works, but cannot configure security. Tried to reset via the reset button. Tried unplugging and tried unplugging the modem. I would like to fix.

    Modem... doing and... model number you have?

    What operating system do you use on your Mac, or you are using an iPhone or iPad set things up... or a PC?

  • Your device is not configured correctly(code 1) error

    Hello

    I have windows XP currently installed on my computer and I also have the new hard drive (seagate 500 gb) installed on my computer.
    I am facing the error with my cell phone (samsung galaxy s duos GT s7562) with my computer and I am unable to make any transfer of media through the PSG.
    Under portable devices > PSG > properties, I get the following message. > "this device is not configured correctly. (Code 1)
    To reinstall the drivers for this device, click on reinstall. When I try update driver it shows "your device is not configured correctly (code 1 error). I tried gel and reinstall driver MTP via "scan for hardware changes", but it does not yet solve my problem.
    How can I get my samsung android smart phone connected to my pc and start sharing media through the PSG. problem certainly lies in the pc.
    Help me out.i am going nuts about that...
    Pankaj.

    Hey,.

    have you found this KB link?

    See "Code 1" from the link

    Explanation of error codes generated by Device Manager in Windows XP Professional

    http://support.Microsoft.com/kb/310123/en-us

  • Windows ip configuration is an internal error: the request is not supported

    I cleaned up a few viruses out of a Windows XP Professional computer to a customer, and now he can't go on the internet.  When I check ipconfig, I get the following error.

    Windows IP configuration
    An internal error has occurred: the request is not supported.
    Contact Microsoft technical support for more help.
    additional information: host name of request impossible.
    So I googled some results. Have replaced the TCPIP.sys file with one from another computer, I still get the same message.  I don't have a windows XP original disk to put it into recovery mode.
    I also ran the command "netsh int ip resetlog.txt" but which did not help either.  I saw on another blog.
    The NIC is to see that there is a power cable plugged into it as well.  Help, please!
    Thank you
    Trever

    Hello Trever,

    Follow the methods and check:

    Method 1: You can refer the following Microsoft Knowledge Base article and check.

    "Error 1068" error message when you try to enable Internet connection sharing

    http://support.Microsoft.com/kb/827328

    Method 2: Try the SFC (System File Checker) scan on the computer.

    To run the System File Checker tool, follow these steps:

    a. click Start and click run, then type cmd in the box start the search.

    b. right click on cmd in the list programs, and then click run as administrator.

    c. If you are prompted for an administrator password or a confirmation, type your password or click on continue

    d. at the command prompt, the following line and press ENTER:

    sfc/scannow

    For more information, see the article:

     

    Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

    http://support.Microsoft.com/kb/310747

     

    File system (CFS) Checker

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/system_file_checker.mspx?mfr=true

    Let us know if that helps.

  • I need help for configuring security for my wireless again.

    Need a help for my Wi - Fi Protected Access set up again... somehow I deleted it while trying to access the networks wireless outside my house.

    original title: Wi - Fi Protected Access

    Hi dmcangus,

    See the Microsoft articles below for more information on WPA wireless security.

    Configure Security Wireless WPA for home networks

    http://Windows.Microsoft.com/en-us/Windows-XP/help/networking/configure-WPA-wireless-security

    Overview of upgrading security Wi - Fi Protected Access (WPA) in Windows XP

    http://support.Microsoft.com/kb/815485

  • Windows mail user name and password appear invalid username and password Port110 Secure (ssc) sever error: 0X8000CCC90 error number0X8000CCC92

    original title: windows mail windows security ask user name and password that has never been there before and error appears the invalid username and password Port110 Secure (ssc) sever error: 0X8000CCC90 error number0X8000CCC92

    Error invalid username and password Port110 Secure sever error: 0X800CCC90 error number0X800CCC92

    This thread was on Windows Mail, not Windows Live Mail.
     
  • How to configure security center than antivirus program is installed when installed in 32-bit vista sp 1.

    could someone tell me how to configure Security Center that I install the basics of security of microsoft and anti virus program installed sercurity interface of Green Center but in section proformance and monitor system health report in the warnings section, it says not installed or antivirus detected please someone help like it _ me off thx.soz.

    It comes with Vista, upgrade install and activate Forum.

    Microsoft Security Essentials questions should be directed to the MSE Forums:

    http://social.answers.Microsoft.com/forums/en-us/msestart/threads

    Installing and upgrading Microsoft Security Essentials program.

    http://social.answers.Microsoft.com/forums/en-us/msescan/threads

    Analysis, detection and removal of threats

    http://social.answers.Microsoft.com/forums/en-us/mseupdate/threads

    Update the definitions of spyware and viruses

    See you soon.

    Mick Murphy - Microsoft partner

  • VLANS can be configured at the vSwitch and Portgroup level?

    Dear friends,

    I hope that all do you good...

    Two statements are true about groups of ports and VLAN defined on a switch vNetwork Standard? (Choose two)

    A. A VLAN can be configured for the entire virtual switch or on groups of individual ports

    B. several groups of ports can specify the same VLAN

    C. VLAN can only be configured on individual port groups

    D. several VLANS can be specified in a port group

    VLANS can be configured at the vSwitch and Portgroup level?

    B. several groups of ports can specify the same VLAN

    C. VLAN can only be configured on individual port groups

  • Hello! I work with the Director 12, Windows 7. A fatal error occurred during my attempt to chance the script police. Now this fatal error occurred whenever I start the Director. I shut down the system and tried again, even failure. What can I do?

    Hello!

    I work with the Director 12, Windows 7. A fatal error occurred during my attempt to chance the script police. Now this fatal error occurred whenever I start the Director. I shut down the system and tried again, even failure.

    What can I do?

    Save the relevant keys, then search your registry at HKCU\Software\Adobe\Director\12\Script

    If this does not help, save the entire branch and try to delete it

  • vCenter Appliance Web Configuration of Client SSO error

    Currently have a vSphere 4.1 with two hosts ESXi environment.  vCenter is on a VM dediated on a single host.

    I'm moving to 5.1 and have chosen to deploy the unit vCenter instead of upgrading my VM.  A through the deployment and installation of the device through the web GUI.  Everything seemed to have configured correctly (DB, SSO, AD auth, etc.).  This is where it gets weird.

    I can access the vCenter via web client uses Windows authentication.  By using the same user credentials in the local client on my computer, it says I don't have permission.  In the web client, when I go to Administration-> Sign-On and discovery-> Configuration, I get an error on any tab, I selected:

    Error: com.vmware.vim.binding.sso.fault.InvalidCredentials:

    inherited from com.vmware.vim.binding.vmodl.fault.SecurityError:

    inherited from com.vmware.vim.binding.sso.fault.InvalidCredentials

    I'm about to give up and just upgrade my current vCenter, but I like the idea of the dedicated device.  I can't find any documentation on this error, or what I'm doing wrong.  It is very difficult to find documentation on the device.

    Thoughts? v

    Well, I can't tell you how to solve this problem, but maybe Kendrick Coleman 5.1 vSphere vCenter Virtual Appliance and vSphere Client video tutorial Web series will help you to successfully deploy the vCenter Server Appliance. At least she helped me to solve some problems I had with the first installations.

    André

  • Whenever I try to install creative cloud on my computer I couldn't install error 1. I used adobe cleaner as suggested, turned off my security, but always error 1.

    Whenever I try to install creative cloud on my computer I couldn't install error 1. I used adobe cleaner as suggested, turned off my security, but always error 1.

    Lucy Sack you used the steps that are listed in the "failed to install" error Creative Cloud Desktop application to solve common mistake?

  • Cannot be rotated PDFs with script (not allowed to avoid error, security settings for error)

    I use a script to rotate each pages in pdf format by clicking on a button. I added a script to rotate the file in the click event of the button turn as a javascript. It works in acrobat, but not in adobe reader. Please see the script

    Start = 0;

    nEnd = this.numPages - 1;

    nRotate = 90;
    Try
    {
    If (this.numPages > 0)
    {
    this.setPageRotations (start, nEnd, nRotate)
    }
    }
    catch (e)
    {
    App.Alert ("processing error:" + e)
    }

    But I get this error in adobe reader not in acrobat. "not authorized error security settings prevent access to this property or method". What is the problem. Please someone tell me.

    I got job usig by installing a script on the local computer. Thank you

  • When opening firefox, a box pops up: [error JAva.script:] "TypeError: netscape.security.PrivilegeManager is not defined.

    Using windows 7 Home premium svc pack 1 64-bit. After that my last windows update the above issue appears when you first start of firefox. Can I close the error msg and it seems that everything works fine. It's boring, but my major concern is security. Any suggestions?

    Thank you

    If it works in Mode safe mode and normal mode with all extensions (Firefox/tools > Modules > Extensions) off and then try to find which extension is the cause by allowing an extension at a time until the problem reappears.

    Close and restart Firefox after each change via "Firefox > Exit ' (Windows: Firefox/file > quit;) Mac: Firefox > quit Firefox. Linux: Firefox/file > exit)

  • My Windows Vista is not all important security updates. Error message that says that one or more components of Windows Update are configured incorrectly.

    I have tried to trouble IT 50202, but which failed due to the error 2678!  Support center has no solution.  Microsoft site does not have its own error code 2678.  Ridiculous.

    This was a huge waste of time and effort because he tries and fails to reinstall everytime I stop.

    RECAP:

    • You bought the computer in January 2009;
    • The computer came with a preinstalled free McAfee;
    • A McAfee application was permanently installed until you have installed Microsoft Security Essentials (MSE) on 23 August 2012;
    • You first met the problems associated with malware (according to MBAM) in June 2010, the first year of your McAfee subscription.
    • You have problems with Windows Update (MSE) on October 12, 2013, more than a year after you have installed MSE;
    • You have improved the pre-installed McAfee free trial to the full version rather than uninstall the free trialware, running the tool to remove McAfee & then make a clean installation of the paid version.
    • You have uninstalled the McAfee application until you have installed MSE but you don't not download/run the removal tool from McAfee before installing MSE.

    MY HUMBLE OPINION...

    • It was too late for the "come to the rescue" McAfee removal tool here.
    • There is a possibility, but remote, you see the effects of an infection for a long time of a certain type (because MSE has not been installed correctly & so never worked properly due to 'remains' of McAfee).
    • The computer must be connected to the internet or local networks (i.e. other computers) in its current state. All your personal data (e.g., banking online & passwords credit card) must be considered at risk, if not already compromised.

    Then what are you doing now?

    OPTION A: You can get Microsoft-sponsored Premium (i.e., paid) supported by the Office of response-online http://answerdesk.microsoftstore.com [1]

    OPTION B (highly recommended): see the poster in this thread and follow the instructions of (my) WHOLE (to-the-letter & in order! ) to restore your computer to a State safe & functional: http://answers.microsoft.com/thread/c44429fb-3f7c-4646-8529-5a97bb3cd0eb

    If you need additional help with the clean install, please start your own new thread in this forum & advice: http://answers.microsoft.com/en-us/windows/forum/windows_vista-system

    If these procedures are outside your technique "comfort zone" - and there is no shame in admitting this isn't your cup of tea - take the local computer, reputable and independent (i.e., not a 'BigBoxStore' or Geek Squad!) computer repair shop & let them do the work.

    OPTION C: Bite the bullet & buy a new computer (Win7).

    • If you want to transfer your personal data to the new computer, backup data from one or more DVDs (no shine). Perform analyses considered at least two 2 online (e.g., ESET;) Kaspersky; Bit Defender) of the DVD (s) before you transfer the data to the new computer.

    Wish I had better news for you, Roz.  Good luck!  On & off...

    =================================================
    [1] $99.00 USD for up to (1) hour of distance support; tax must be paid in advance; no guarantee whatsoever

  • Script for VMkernel Port of vMA error

    I used this script in the past for various automated creations (thanks to Lamw).  But I seem to have a problem at the level of the #32 (in bold and in blue) line in the script.  When I try to create the VMkernel port saying it in the vMA-error "cannot add the vmkernel nic: a specified parameter was not correct. ««» Vim.Host.VirtualNic.Specification.Ip ".  Can someone please look at what the problem with the script of m?  Thanks to advanced.

    Here is my Config file

    esxiserver.mydoamin.com:vSwitch1:ISCSI01:125:167.237.125.38:255.255.255.128

    Here's the Script:

    #! / bin/sh

    If [$#-1]; then
    echo "Please indicate the configuration input file.
    Output 1
    FI

    CONFIG = $1

    FIRST_HOST = $(head-1 ${CONFIG} | awk-F ":" '{print $1}')
    source/opt/vmware/vma/bin/vifptarget if ${FIRST_HOST} > / dev/null 2 > & 1

    If [$?-eq 0]; then
    IFS = $' \n '.
    for the LINE $(cat ${CONFIG});
    do
    VIHOST = $(echo ${LIGNE} | awk-F ":" '{print $1}')
    VSWITCH = $(echo ${LIGNE} | awk-F ":" '{print $2}")
    PORTGROUP = $(echo ${LIGNE} | awk-F ":" '{print $3}")
    VLAN = $(echo ${LIGNE} | awk-F ":" '{print $4}')
    IP = $(echo ${LIGNE} | awk-F ":" '{print $5}')
    NETMASK = $(echo ${LIGNE} | awk-F ":" '{print $6}")
    echo ' create a new vSwitch with frames ${VSWITCH} on target ${VIHOST} ".
    / usr/bin/esxcfg-vswitch - server $ of {VIHOST} - ${VSWITCH}
    / usr/bin/esxcfg-vswitch - m - 9000 Server ${VIHOST} {VSWITCH}
    / usr/bin/esxcfg-vswitch - Server ${VIHOST}-L vmnic2 ${VSWITCH}
    / usr/bin/esxcfg-vswitch - Server ${VIHOST}-L vmnic3 ${VSWITCH}
    echo "adding new portgroup ${PORTGROUP} with VLAN ${VLAN}.
    / usr/bin/esxcfg-vswitch - Server ${VIHOST}-{PORTGROUP} ${VSWITCH}
    / usr/bin/esxcfg-vswitch - Server ${VIHOST} {PORTGROUP} Pei - v ${VLAN} ${VSWITCH}
    echo "Creating VMkernel Port ${PORTGROUP} with IP ${IP} PORTGROUP $ {PORTGROUP}.

    /usr/bin/esxcfg-vmknic - Server ${VIHOST} - a-i ${IP} - n {MASK} m $9000 {PORTGROUP} -what IS the ERROR in THE SCRIPT

    ECHO
    fact
    unset IFS
    on the other
    echo "failed to initialize the vi-fastpass on target ${FIRST_HOST}".
    Output 1

    If you script is called blah.sh, rather than run comme./blah.sh run it with sh - x blah.sh. This produces a result more to see what variables/etc. get the script runs through its logic. It's an easy way to debug

    The error you see is nothing with the script, I think whether you're creating a portgroup, then the interface back to back and it might happen too fast and so you get an error with the entry. Easy way to check this is to add sleep command before you create the VMkernel interface and see if that helps

Maybe you are looking for