Compare commits
6
Commits
201e579d85
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
368d8318fd | ||
|
|
93c4a12927 | ||
|
|
07be3af454 | ||
|
|
3c95ec52e7 | ||
|
|
c43a68cf6f | ||
|
|
400273c2ee |
No files matched your search
@@ -1,6 +1,5 @@
|
|||||||
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
$KISHorizon_version="2.0.0"
|
||||||
throw "This module requires PowerShell 7 or higher. You are currently running version $($PSVersionTable.PSVersion)."
|
$KISHorizon_release="2026-10-02"
|
||||||
}
|
|
||||||
|
|
||||||
$global:request_header = @{
|
$global:request_header = @{
|
||||||
"accept"="*/*"
|
"accept"="*/*"
|
||||||
@@ -707,10 +706,12 @@ function Grant-HorizonDesktop {
|
|||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
Success = $false
|
Success = $false
|
||||||
Message = "Neither UserName nor UserUPN were provided."
|
Message = "Neither UserName nor UserUPN were provided."
|
||||||
|
status_code = 9999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$MachineID = (Get-HorizonMachine -Horizon $Horizon | where {$_.name -eq $MachineName}).id
|
$mymachine = Get-HorizonMachine -Horizon $Horizon | where {$_.name -eq $MachineName}
|
||||||
|
$MachineID = $mymachine.id
|
||||||
if ($global:kishorizondebug) {
|
if ($global:kishorizondebug) {
|
||||||
Write-Host MachineID: $MachineID
|
Write-Host MachineID: $MachineID
|
||||||
}
|
}
|
||||||
@@ -718,13 +719,14 @@ function Grant-HorizonDesktop {
|
|||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
Success = $false
|
Success = $false
|
||||||
Message = "Machine $MachneName does not exist in any desktop pool."
|
Message = "Machine $MachneName does not exist in any desktop pool."
|
||||||
|
status_code = 9999
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($UserName -ne "") {
|
if ($UserName -ne "") {
|
||||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -UserName $UserName).id
|
$User = Get-HorizonAdUser -Horizon $Horizon -UserName $UserName
|
||||||
} else {
|
} else {
|
||||||
$UserID = (Get-HorizonAdUser -Horizon $Horizon -UPN $UserUPN).id
|
$User = Get-HorizonAdUser -Horizon $Horizon -UPN $UserUPN
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($global:kishorizondebug) {
|
if ($global:kishorizondebug) {
|
||||||
@@ -735,6 +737,18 @@ function Grant-HorizonDesktop {
|
|||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
Success = $false
|
Success = $false
|
||||||
Message = User $UserUPN cannot be found.
|
Message = User $UserUPN cannot be found.
|
||||||
|
status_code = 9999
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mymachine.PSObject.Properties['user_ids']) {
|
||||||
|
if ($User.id -in $mymachine.user_ids) {
|
||||||
|
if ($User
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
Success = $false
|
||||||
|
Message = User $UserUPN already assigned to computer $MachineName.
|
||||||
|
status_code = 9999
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+44524
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,4 @@
|
|||||||
#requires -Modules posh-ssh
|
##requires -Modules posh-ssh
|
||||||
|
|
||||||
param (
|
param (
|
||||||
[string]$vCenter = "",
|
[string]$vCenter = "",
|
||||||
@@ -9,8 +9,8 @@ param (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
$FileVersion = "1.0.1"
|
$FileVersion = "1.1.0"
|
||||||
$FileDate = "2026-04-18"
|
$FileDate = "2026-10-06"
|
||||||
|
|
||||||
# Display Script Banner
|
# Display Script Banner
|
||||||
Write-Host "--------------------------------------------------" -ForegroundColor White
|
Write-Host "--------------------------------------------------" -ForegroundColor White
|
||||||
@@ -19,6 +19,31 @@ Write-Host "Version $($FileVersion) ($($FileDate))" -ForegroundColor Green
|
|||||||
Write-Host "Written by Charlie Silverman" -ForegroundColor Green
|
Write-Host "Written by Charlie Silverman" -ForegroundColor Green
|
||||||
Write-Host "--------------------------------------------------" -ForegroundColor White
|
Write-Host "--------------------------------------------------" -ForegroundColor White
|
||||||
|
|
||||||
|
function CheckModuleInstalled($moduleName, $command) {
|
||||||
|
Write-Host "Checking that package $moduleName is installed..." -NoNewLine
|
||||||
|
if (-not(get-command $command -erroraction silentlycontinue)) {
|
||||||
|
Write-Host " Missing" -ForegroundColor Red
|
||||||
|
if (-not (Get-Module -ListAvailable -Name $moduleName)) {
|
||||||
|
$response = ""
|
||||||
|
while (($response -ne "yes") -and ($response -ne "no")) {
|
||||||
|
$response = (Read-Host "$moduleName module not instaled. Install now? (yes/no)").ToLower()
|
||||||
|
}
|
||||||
|
if ($response -eq "no") {
|
||||||
|
Write-Host "Operation Cancelled." -ForegroundColor Yellow
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
Write-Host "Installing PowerShell module $moduleName..." -NoNewLine
|
||||||
|
Install-Module -Name $moduleName -Scope CurrentUser -Force
|
||||||
|
Write-Host " Success" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
Write-Host "Loading PowerShell module $moduleName..." -NoNewLine
|
||||||
|
Import-Module $moduleName
|
||||||
|
Write-Host " Success" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " Found" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($Help) {
|
if ($Help) {
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host "Purpose: Run a CLI command on all hosts in a cluster."
|
Write-Host "Purpose: Run a CLI command on all hosts in a cluster."
|
||||||
@@ -44,6 +69,8 @@ if ($Help) {
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckModuleInstalled -moduleName "posh-ssh" -command "New-SSHSession"
|
||||||
|
|
||||||
$quiet = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
|
$quiet = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
|
||||||
|
|
||||||
if ($vCenter -eq "") {
|
if ($vCenter -eq "") {
|
||||||
|
|||||||
Reference in new issue
Block a user