PoshCode Logo PowerShell Code Repository

Disable-CopyPasta-1.ps1 (modification of post by view diff)
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1475"></script>download | new post

Updated

  1. Begin {
  2.  
  3.         $disableCopy = "isolation.tools.copy.enable"
  4.         $disableCopy_value = "false"
  5.         $disablePaste = "isolation.tools.paste.enable"
  6.         $disablePaste_value = "false"
  7.         $disableGUI = "isolation.tools.setGUIOptions.enable"
  8.         $disableGUI_value = "false"
  9. }
  10.  
  11. Process {
  12.     #Make Sure it's a VM
  13.         if ( $_ -isnot [VMware.VimAutomation.Client20.VirtualMachineImpl] ) { co ntinue  }
  14.  
  15.         #Setup our Object
  16.         $vm = Get-View $_.Id
  17.         $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
  18.         $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
  19.         $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
  20.         $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
  21.         $vmConfigSpec.extraconfig[0].Key=$disableCopy
  22.         $vmConfigSpec.extraconfig[0].Value=$disableCopy_value
  23.         $vmConfigSpec.extraconfig[1].Key=$disablePaste
  24.         $vmConfigSpec.extraconfig[1].Value=$disablePaste_value
  25.         $vmConfigSpec.extraconfig[2].Key=$disableGUI
  26.         $vmConfigSpec.extraconfig[2].Value=$disableGUI_value
  27.         #Run the change
  28.         $vm.ReconfigVM($vmConfigSpec)
  29. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me