Skip to content

Instantly share code, notes, and snippets.

@lazywinadmin
Last active December 19, 2015 01:09
Show Gist options
  • Save lazywinadmin/5873393 to your computer and use it in GitHub Desktop.
Save lazywinadmin/5873393 to your computer and use it in GitHub Desktop.
#requires -Version 3.0
#requires -PSSnapin VMware.VimAutomation.Core
function Disable-VMCopyPaste
{
[CmdletBinding()]
PARAM(
[string[]]$vm
)
BEGIN{
Write-Verbose -Message "Checking if there is any VI Server Active Connection"
if(-not($global:DefaultVIServers.count -gt 0)){
Write-Warning -Message "Wow You are not connected to any Vi Server. Use Connect-ViServer first"
break
}
Write-Verbose -Message "At least one VI Server Active Connection Found"
}
PROCESS{
TRY{
foreach ($item in $vm){
Write-Verbose -Message "$item - Setting the isolation.tools.copy.disable AdvancedSetting to $true..."
New-AdvancedSetting `
-Entity $item `
-Name isolation.tools.copy.disable `
-Value $true `
-confirm:$false `
-force:$true `
-errorAction 'Continue'
Write-Verbose -Message "$item - Setting the isolation.tools.paste.disable AdvancedSetting to $true..."
New-AdvancedSetting `
-Entity $item `
-Name isolation.tools.paste.disable `
-Value $true `
-confirm:$false `
-force:$true `
-errorAction 'Continue'
}
}
CATCH{
Write-Warning -Message "Wow Something went wrong with $item"
}
FINALLY{}
}
END{Write-Verbose -Message "Script completed"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment