Update KISHorizon.psm1
This commit is contained in:
1 parent
205d434afc
commit
e6bb5f2e14
1 file changed
+22
-10
@@ -539,6 +539,7 @@ Function Get-HorizonADUser {
|
||||
[string]$Domain = "",
|
||||
[string]$Id = "",
|
||||
[string]$Name = "",
|
||||
[string]$UPN = "",
|
||||
[int]$Page = 0,
|
||||
[int]$PageSize = 0
|
||||
)
|
||||
@@ -567,15 +568,17 @@ Function Get-HorizonADUser {
|
||||
}
|
||||
|
||||
if ($Name -ne "") {
|
||||
$extension = "?group_only=false&filter={`"type`":`"Or`",`"filters`":[{`"type`":`"Equals`",`"name`":`"user_principal_name`",`"value`":`"$Name`"},{`"type`":`"Equals`",`"name`":`"login_name`",`"value`":`"$Name`"}]}"
|
||||
$extension = "?group_only=false&filter={`"type`":`"Equals`",`"name`":`"login_name`",`"value`":`"$Name`"}"
|
||||
}
|
||||
|
||||
if ($UPN -ne "") {
|
||||
$extension = "?group_only=false&filter={`"type`":`"Equals`",`"name`":`"user_principal_name`",`"value`":`"$UPN`"}"
|
||||
}
|
||||
|
||||
$userlookupURI += $extension
|
||||
|
||||
if ($global:kishorizondebug) {
|
||||
Write-Host $MyInvocation.MyCommand.Name Starting
|
||||
Write-Host User: $Name
|
||||
Write-Host Domain: $Domain
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -680,7 +683,8 @@ function Grant-HorizonDesktop {
|
||||
param (
|
||||
[parameter(Mandatory = $true, ValueFromPipeline = $true)] $Horizon,
|
||||
[parameter(Mandatory = $true)] $MachineName,
|
||||
[parameter(Mandatory = $true)] $UserUPN
|
||||
[string] $UserUPN = "",
|
||||
[string] $UserName = ""
|
||||
)
|
||||
$token = $Horizon.access_token
|
||||
$server = $Horizon.server_name
|
||||
@@ -692,6 +696,13 @@ function Grant-HorizonDesktop {
|
||||
Write-Host $MyInvocation.MyCommand.Name Starting
|
||||
}
|
||||
|
||||
if ($UserUPN -eq "" -and $UserName -eq "") {
|
||||
return [PSCustomObject]@{
|
||||
Success = $false
|
||||
Message = Neither UserName nor UserUPN were provided.
|
||||
}
|
||||
}
|
||||
|
||||
$MachineID = (Get-HorizonMachine -Horizon $Horizon | where {$_.name -eq $MachineName}).id
|
||||
if ($global:kishorizondebug) {
|
||||
Write-Host MachineID: $MachineID
|
||||
@@ -699,22 +710,23 @@ function Grant-HorizonDesktop {
|
||||
if ($MachineID -eq $null) {
|
||||
return [PSCustomObject]@{
|
||||
Success = $false
|
||||
Message = "Machine $MachineName does not exist in any desktop pool."
|
||||
Message = Machine $MachneName does not exist in any desktop pool.
|
||||
}
|
||||
}
|
||||
$nameparts = $UserUPN.split("\")
|
||||
if ($nameparts.Count -gt 1) {
|
||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -Name $nameparts[1] -domain $nameparts[0]).id
|
||||
|
||||
if ($UserName -ne "") {
|
||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -UserName $Name).id
|
||||
} else {
|
||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -Name $UseUPN).id
|
||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -UPN $UserUPN).id
|
||||
}
|
||||
|
||||
if ($global:kishorizondebug) {
|
||||
Write-Host UserID: $UserID
|
||||
}
|
||||
if ($UserID -eq $null) {
|
||||
return [PSCustomObject]@{
|
||||
Success = $false
|
||||
Message = "User $UserUPN cannot be found."
|
||||
Message = User $UserUPN cannot be found.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user