# encoding: ascii
# api: powershell
# title: Create a VIAccount
# description: Create a VIAccount object suitable for use with New-VIPermission, Get-VIPermission, etc. from PowerCLI.
# version: 0.1
# type: function
# license: CC0
# function: New-VIAccount
# x-poshcode-id: 1517
# x-archived: 2009-12-12T18:33:18
#
#
function New-VIAccount($principal) {
	$flags = `
		[System.Reflection.BindingFlags]::NonPublic    -bor
		[System.Reflection.BindingFlags]::Public       -bor
		[System.Reflection.BindingFlags]::DeclaredOnly -bor
		[System.Reflection.BindingFlags]::Instance
	$method = $defaultviserver.GetType().GetMethods($flags) |
		where { $_.Name -eq "VMware.VimAutomation.Types.VIObjectCore.get_Client" }
	$client = $method.Invoke($global:DefaultVIServer, $null)
	Write-Output `
		(New-Object VMware.VimAutomation.Client20.PermissionManagement.VCUserAccountImpl `
			-ArgumentList $principal, "", $client)
}
