Skip to content

Instantly share code, notes, and snippets.

@raulunzue
Last active August 25, 2020 08:27
Show Gist options
  • Save raulunzue/1fe865097887d2a75234f6fb7aaef5ff to your computer and use it in GitHub Desktop.
Save raulunzue/1fe865097887d2a75234f6fb7aaef5ff to your computer and use it in GitHub Desktop.
######################################
# SCRIPT EL BLOG DE NEGU - RAUL UNZUE
#####################################
# Pasamos la ruta a nuestro PATH
$env:Path = $env:Path + ';C:\Program Files (x86)\Citrix\Licensing\LS\'
# Obtener licencias
$FilePath = "C:\Scripts\Citrix_Licence_Used.txt"
#$Exe = "C:\Program Files (x86)\Citrix\Licensing\LS"
#cd $Exe
#./udadmin.exe -list -f “XDT_ENT_UD” | Select-String “XDT_ENT_UD 2021.0524” | out-file $FilePath
& 'C:\Program Files (x86)\Citrix\Licensing\LS\udadmin.exe' -list -f "XDT_ENT_UD" | Select-String "XDT_ENT_UD 2021.0524" | out-file $FilePath
# Limpiamos el fichero de espacios en blanco
(gc $FilePath) | ? {$_.trim() -ne "" } | set-content $FilePath
# Limpiamos los datos para tratarlos y obtener licencias de usuarios/maquinas a liberar
$Licenses = (Select-String -Pattern "XDT" -Path $FilePath ) | ForEach {$_.line -replace " XDT_ENT_UD 2021.0524 ","" }
# Usamos Udadmin para liberar licencias
#ForEach ($Lic in $Licenses) {./udadmin.exe -f "XDT_ENT_UD" -user $Lic -delete}
ForEach ($Lic in $Licenses) {& 'C:\Program Files (x86)\Citrix\Licensing\LS\udadmin.exe' -f "XDT_ENT_UD" -user $Lic -delete}
# Reiniciamos el servicio del servidor de licencias
$svc = (Get-Service -DisplayName "Citrix Licensing")
Restart-Service -InputObject $svc -verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment