├── .GITIGNORE ├── docs ├── .nojekyll ├── use │ ├── use_loadadmin.md │ ├── use_systeminfo.md │ ├── use_tasks.md │ ├── use_connect.md │ ├── use_icons.md │ ├── use_directoryjunction.md │ ├── use_appassignments.md │ ├── use_platlayers.md │ ├── use_applayers.md │ ├── use_oslayers.md │ ├── use_exportimportlayers.md │ ├── use_connectors.md │ └── use_images.md ├── install.md ├── Makefile ├── index.rst ├── make.bat ├── changelog.rst └── cmd │ ├── cmd_disconnect.rst │ ├── cmd_connect.rst │ ├── cmd_stop.rst │ └── cmd_export.rst ├── Examples ├── README.MD ├── GetUserAppAssignments.ps1 └── UpdateTask.ps1 ├── .github └── FUNDING.yml ├── Tests ├── ctxal-sdk.tests.ps1 └── Main.tests.ps1 ├── ctxal-sdk ├── ctxal-sdk.psm1 ├── Public │ ├── Get-ALVMName.ps1 │ ├── disconnect-alsession.ps1 │ ├── Get-ALconnectoragent.ps1 │ ├── get-alCachePointInfo.ps1 │ ├── get-alicon.ps1 │ ├── get-aliconassoc.ps1 │ ├── stop-alworkticket.ps1 │ ├── Get-AlLocalUser.ps1 │ ├── remove-alicon.ps1 │ ├── get-alimage.ps1 │ ├── get-aloslayer.ps1 │ ├── get-alSystemsettingInfo.ps1 │ ├── get-alDirectoryDetail.ps1 │ ├── get-alremoteshare.ps1 │ ├── get-alplatformlayer.ps1 │ ├── get-alapplayer.ps1 │ ├── Get-ALPendingOp.ps1 │ ├── get-alimageDetail.ps1 │ ├── get-alconnectortype.ps1 │ ├── get-aloslayerdetail.ps1 │ ├── get-alSysteminfo.ps1 │ ├── get-allayerinstalldisk.ps1 │ ├── get-alstatus.ps1 │ ├── get-alplatformlayerDetail.ps1 │ ├── get-alapplayerdetail.ps1 │ ├── remove-alconnector.ps1 │ ├── Remove-ALImage.ps1 │ ├── New-ALImageClone.ps1 │ ├── remove-aldirectory.ps1 │ ├── invoke-alCreateBundle.ps1 │ ├── get-alconnector.ps1 │ ├── get-aluserassignment.ps1 │ ├── new-alicon.ps1 │ ├── get-alvcenterconnector.ps1 │ ├── Get-ALDirectory.ps1 │ ├── set-alvcenterconnector.ps1 │ ├── get-alAuditInfo.ps1 │ ├── Get-ALConnectorDetail.ps1 │ ├── get-aluserDetail.ps1 │ ├── remove-alappassignment.ps1 │ ├── get-alusergroupmembership.ps1 │ ├── remove-aloslayerrev.ps1 │ ├── Set-ALAdminUser.ps1 │ ├── remove-alapplayerrev.ps1 │ ├── get-aluserlist.ps1 │ ├── add-alappassignment.ps1 │ ├── get-alldapobject.ps1 │ ├── remove-alplatformlayerrev.ps1 │ ├── remove-alelappassignment.ps1 │ ├── invoke-allayerfinalize.ps1 │ ├── connect-alsession.ps1 │ ├── Set-ALConnectorCred.ps1 │ ├── Invoke-ALPublish.ps1 │ ├── new-alapplayerclone.ps1 │ ├── Export-allayerrev.ps1 │ ├── Import-allayerrev.ps1 │ ├── test-aldirectory.ps1 │ ├── Set-ALOslayer.ps1 │ ├── Set-ALPlatformlayer.ps1 │ ├── add-alelappassignment.ps1 │ ├── test-aldirectoryauth.ps1 │ └── set-alapplayer.ps1 └── Private │ ├── Test-ALWebsession.ps1 │ └── Test-ALRemoteFileShare.ps1 ├── AppVeyor ├── helpers.ps1 ├── builddocs.ps1 └── deploy.ps1 ├── LICENSE └── appveyor.yml /.GITIGNORE: -------------------------------------------------------------------------------- 1 | .vscode -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Examples/README.MD: -------------------------------------------------------------------------------- 1 | Check out https://www.techdrabble.com/citrix/app-layering/34-automating-app-and-os-layers for usage -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: ryancbutler 4 | custom: ["https://paypal.me/ryancbutler","https://www.buymeacoffee.com/ryancbutler"] 5 | -------------------------------------------------------------------------------- /docs/use/use_loadadmin.md: -------------------------------------------------------------------------------- 1 | # Local Users 2 | 3 | ## Get Local Users 4 | 5 | ```powershell 6 | Get-ALLocalUser -websession $websession 7 | ``` 8 | 9 | ## Set Local Admin Password 10 | 11 | ```powershell 12 | Set-ALAdminUser -websession $websession -Password $PlainPassword -Verbose 13 | ``` -------------------------------------------------------------------------------- /docs/use/use_systeminfo.md: -------------------------------------------------------------------------------- 1 | # System Info 2 | 3 | ## Get System Information (Version) 4 | 5 | ```powershell 6 | Get-ALSystemInfo -websession $websession 7 | ``` 8 | 9 | ## Get System Settings 10 | 11 | ```powershell 12 | get-alsystemsettinginfo -websession $websession|Select-Object -ExpandProperty value -Property @{Name="SettingName"; Expression = {$_.Name}} 13 | ``` -------------------------------------------------------------------------------- /Tests/ctxal-sdk.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Module Metadata Validation' { 2 | it 'Script fileinfo should be ok' { 3 | {Test-ModuleManifest ".\ctxal-sdk\ctxal-sdk.psd1" -ErrorAction Stop} | Should -Not -Throw 4 | } 5 | 6 | it 'Import module should be ok'{ 7 | {Import-Module ".\ctxal-sdk\ctxal-sdk.psm1"-Force -ErrorAction Stop} | Should -Not -Throw 8 | } 9 | } -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # Install and Update 2 | 3 | ## Install Manually 4 | 5 | ```powershell 6 | Import-Module ".\ctxal-sdk.psm1" 7 | ``` 8 | 9 | ## Install PSGallery 10 | 11 | ```powershell 12 | Find-Module -name ctxal-sdk 13 | Install-Module -Name ctxal-sdk -Scope CurrentUser 14 | ``` 15 | 16 | ## Update PSGallery 17 | 18 | ```powershell 19 | Find-Module -name ctxal-sdk 20 | Update-Module -Name ctxal-sdk 21 | ``` 22 | `` -------------------------------------------------------------------------------- /docs/use/use_tasks.md: -------------------------------------------------------------------------------- 1 | # Task Status 2 | 3 | ## Get Task Status 4 | Get all tasks 5 | 6 | ```powershell 7 | Get-ALStatus -websession $websession 8 | ``` 9 | 10 | Get specific task based on ID (accepts wildcard) 11 | ```powershell 12 | Get-ALStatus -id 123456 -websession $websession 13 | ``` 14 | 15 | ## Cancel Task 16 | Locate ID of Task `Get-ALStatus -websession $websession` 17 | 18 | ```powershell 19 | Stop-ALWorkTicket -id 123456 -websession $websession 20 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/ctxal-sdk.psm1: -------------------------------------------------------------------------------- 1 | $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) 2 | $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) 3 | 4 | #Dot source the files 5 | Foreach($import in @($Public + $Private)) 6 | { 7 | Try 8 | { 9 | . $import.fullname 10 | } 11 | Catch 12 | { 13 | Write-Error -Message "Failed to import function $($import.fullname): $_" 14 | } 15 | } -------------------------------------------------------------------------------- /docs/use/use_connect.md: -------------------------------------------------------------------------------- 1 | # Connect and Disconnect 2 | 3 | ## Connect 4 | 5 | ```powershell 6 | $aplip = "192.168.1.5" 7 | $pass = "Password" 8 | $username = "administrator" 9 | $SecurePassword = ConvertTo-SecureString $Pass -AsPlainText -Force 10 | $Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword) 11 | $websession = Connect-alsession -aplip $aplip -Credential $Credential -Verbose 12 | ``` 13 | 14 | ## Disconnect 15 | 16 | ```powershell 17 | disconnect-alsession -websession $websession 18 | ``` -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = . 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Citrix App Layering PowerShell SDK (BETA) 2 | ========================================= 3 | 4 | This is a reversed engineered SDK that emulates the SOAP calls that AL uses to manage the appliance. Currently only supports version **4.11 or later**. **THIS USES UNSUPPORTED API CALLS. PLEASE USE WITH CAUTION.** 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :hidden: 9 | :caption: Getting Started 10 | 11 | install 12 | changelog 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | :hidden: 17 | :glob: 18 | :caption: Command Help 19 | 20 | cmd/* 21 | 22 | .. toctree:: 23 | :maxdepth: 2 24 | :hidden: 25 | :glob: 26 | :caption: Usage Examples 27 | 28 | use/* -------------------------------------------------------------------------------- /AppVeyor/helpers.ps1: -------------------------------------------------------------------------------- 1 | Function Test-Encoding 2 | { 3 | [CmdletBinding()] 4 | Param ( 5 | [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] 6 | [string]$Path 7 | ) 8 | $contents = new-object byte[] 3 9 | $stream = [System.IO.File]::OpenRead($path) 10 | $stream.Read($contents, 0, 3)|out-null 11 | $stream.Close() 12 | ($contents[0] -eq 0x66 -and $contents[1] -eq 0x75 -and $contents[2] -eq 0x6E) -or ($contents[0] -eq 0x20 -and $contents[1] -eq 0x66 -and $contents[2] -eq 0x75) -or ($contents[0] -eq 0x24 -and $contents[1] -eq 0x50 -and $contents[2] -eq 0x75) -or ($contents[0] -eq 70 -and $contents[1] -eq 117 -and $contents[2] -eq 110) 13 | 14 | } -------------------------------------------------------------------------------- /docs/use/use_icons.md: -------------------------------------------------------------------------------- 1 | # Icons 2 | 3 | ## Get icon ids 4 | 5 | ```powershell 6 | Get-ALicon -websession $websession 7 | ``` 8 | 9 | ## Export all icons (save as png) 10 | 11 | ```powershell 12 | $icons = Get-ALicon -websession $websession 13 | 14 | foreach($icon in $icons) 15 | { 16 | #No authentication needed to grab image 17 | Invoke-WebRequest -uri $($icon.url) -OutFile ("D:\Temp\icons\" + $($icon.iconid)+".png") 18 | } 19 | ``` 20 | 21 | ## Get icon associations 22 | 23 | ```powershell 24 | Get-ALiconassoc -websession $websession -iconid "196608" 25 | ``` 26 | 27 | ## Create new icon 28 | 29 | ```powershell 30 | $iconfile = "D:\Temp\icons\myiconpic.png" 31 | $temp = new-alicon -WebSession $websession -iconfile $iconfile -Verbose 32 | ``` 33 | 34 | ## Remove icon 35 | 36 | ```powershell 37 | Remove-ALicon -websession $websession -iconid "4259840" 38 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-ALVMName.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALVMName { 2 | <# 3 | .SYNOPSIS 4 | Extracts VM name out of "action required" task 5 | .DESCRIPTION 6 | Extracts VM name out of "action required" task 7 | .PARAMETER message 8 | Message from pending operation 9 | .EXAMPLE 10 | Get-ALVMName -message $status.WorkItems.WorkItemResult.Status 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$message 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | #Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | $pattern = "(?<=(\]|'))([^'\[]*)-\d\d\d\d-\d\d-\d\d_\d\d-\d\d-\d\d.\d\d\d([^\[']*)(?=(\[|'))" 22 | $result = [regex]::match($message, $pattern) 23 | Write-Verbose $result 24 | return $result.value 25 | } 26 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 27 | } 28 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=. 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /ctxal-sdk/Private/Test-ALWebsession.ps1: -------------------------------------------------------------------------------- 1 | function Test-ALWebsession { 2 | <# 3 | .SYNOPSIS 4 | Tests for valid web request session 5 | .DESCRIPTION 6 | Tests for valid web request session 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Test-ALWebsession -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | [OutputType([System.boolean])] 14 | Param( 15 | [Parameter(Mandatory = $true)]$websession 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | } 20 | Process { 21 | 22 | if ([string]::IsNullOrWhiteSpace($websession.token)) { 23 | throw "Not Connected. Run Connect-ALSession to connect" 24 | } 25 | else { 26 | Write-Verbose "Connection OK" 27 | #return $true 28 | } 29 | 30 | } 31 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 32 | } -------------------------------------------------------------------------------- /AppVeyor/builddocs.ps1: -------------------------------------------------------------------------------- 1 | Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\ctxal-sdk" -Force -Verbose 2 | $verbs = (Get-Command -Module ctxal-sdk).Verb | Select-Object -Unique 3 | 4 | $TextInfo = (Get-Culture).TextInfo 5 | $title = $TextInfo.ToTitleCase($verb) 6 | foreach ($verb in $verbs) 7 | { 8 | $data = @() 9 | $data += "$title Commands" 10 | $data += '=========================' 11 | $data += '' 12 | $data += "This page contains details on **$title** commands." 13 | $data += '' 14 | foreach ($help in (Get-Command -Module ctxal-sdk| Where-Object -FilterScript { 15 | $_.name -like "$verb-*" 16 | })) 17 | { 18 | $data += $help.Name 19 | $data += '-------------------------' 20 | $data += '' 21 | $data += Get-Help -Name $help.name -Detailed 22 | $data += '' 23 | } 24 | 25 | $data | Out-File -FilePath "$env:APPVEYOR_BUILD_FOLDER\docs\cmd\cmd_$($verb.ToLower()).rst" -Encoding utf8 26 | Write-Output " cmd_$($verb.ToLower())" 27 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Ryan Butler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========================= 3 | - 06-01-2018 BETA release 4 | - 06-03-2018 Function for appliance details 5 | - 06-03-2018 Fix in Get-alvmname for message text 6 | - 06-04-2018 Get system info functions 7 | - 06-09-2018 Better response output and clarify examples 8 | - 06-20-2018 Get-ALImageComp function add 9 | - 10-05-2018 Add stop-alworkticket function 10 | - 10-18-2018 Add XenServer OS import option (now vcenter and xenserver) 11 | - 10-18-2018 More detail for Get-ALImageComp 12 | - 10-30-2018 Added functionality to export, view, create, check associations and remove icons 13 | - 11-08-2018 Added functionality to export and import layers to and from network shares 14 | - 11-10-2018 Cleaned up parameters and better get status returns 15 | - 12-29-2018 Added functionality for directory junctions 16 | - 01-22-2019 Added functionality to pull user information and assignments 17 | - 01-22-2019 Much better regex for Get-AlVMName (Thanks Bill Nickerson @wnickerson78) 18 | - 01-29-2019 Added ability to remove layer revisions (Thanks Siebrand Feenstra @Siebrandf) 19 | - 02-18-2019 Added better functionality to see app assignments (See Examples\GetUserAppAssignments) 20 | - 02-21-2019 vCenter Connector commands 21 | - 04-01-2019 Set admin password functionality. Get local accounts 22 | - 04-11-2019 Get connector detail and set connector credentials -------------------------------------------------------------------------------- /ctxal-sdk/Public/disconnect-alsession.ps1: -------------------------------------------------------------------------------- 1 | function Disconnect-ALsession { 2 | <# 3 | .SYNOPSIS 4 | Logs off and disconnects web session 5 | .DESCRIPTION 6 | Logs off and disconnects web session 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Disconnect-ALsession -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | Test-ALWebsession -WebSession $websession 20 | } 21 | Process { 22 | [xml]$xml = @" 23 | 24 | 25 | 26 | 27 | 28 | "@ 29 | Write-Verbose $xml 30 | $headers = @{ 31 | "Content-Type" = "text/xml; charset=utf-8"; 32 | UNIDESK_TOKEN = $websession.token; 33 | SOAPAction = "http://www.unidesk.com/Logout"; 34 | } 35 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 36 | Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession | Out-Null 37 | } 38 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 39 | } 40 | -------------------------------------------------------------------------------- /docs/cmd/cmd_disconnect.rst: -------------------------------------------------------------------------------- 1 | Commands 2 | ========================= 3 | 4 | This page contains details on **** commands. 5 | 6 | Disconnect-ALsession 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Disconnect-ALsession 12 | 13 | SYNOPSIS 14 | Logs off and disconnects web session 15 | 16 | 17 | SYNTAX 18 | Disconnect-ALsession [-websession] [] 19 | 20 | 21 | DESCRIPTION 22 | Logs off and disconnects web session 23 | 24 | 25 | PARAMETERS 26 | -websession 27 | Existing Webrequest session for ELM Appliance 28 | 29 | 30 | This cmdlet supports the common parameters: Verbose, Debug, 31 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 32 | OutBuffer, PipelineVariable, and OutVariable. For more information, see 33 | about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 34 | 35 | -------------------------- EXAMPLE 1 -------------------------- 36 | 37 | PS C:\>Disconnect-ALsession -websession $websession 38 | 39 | 40 | 41 | 42 | 43 | 44 | REMARKS 45 | To see the examples, type: "get-help Disconnect-ALsession -examples". 46 | For more information, type: "get-help Disconnect-ALsession -detailed". 47 | For technical information, type: "get-help Disconnect-ALsession -full". 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-ALconnectoragent.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALconnectoragent { 2 | <# 3 | .SYNOPSIS 4 | Gets connector agents 5 | .DESCRIPTION 6 | Gets connector agents 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALconnectoragent -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" } 17 | 18 | Process { 19 | 20 | #do the request 21 | $headers = @{ 22 | "Cookie" = ("UMCSessionCoookie=" + $($websession.token)) 23 | "Accept" = "*/*" 24 | "Content-Type" = "application/json" 25 | "Host" = "$($websession.aplip):3504" 26 | "Referer" = "https://$($websession.aplip):3504/ui/" 27 | } 28 | try { 29 | $content = Invoke-RestMethod -Method GET -Uri "https://$($websession.aplip):3504/api/Agents?filter[include]=host" -Headers $headers 30 | } 31 | catch { 32 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 33 | if ($temp.message) { 34 | Write-error $temp.message 35 | } 36 | else { 37 | Write-error $temp.error.message 38 | Write-error $temp.error.sqlmessage 39 | write-error $temp.error.staus 40 | } 41 | throw "Process failed!" 42 | } 43 | finally { 44 | 45 | } 46 | 47 | return $content 48 | 49 | 50 | } 51 | 52 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /docs/cmd/cmd_connect.rst: -------------------------------------------------------------------------------- 1 | Commands 2 | ========================= 3 | 4 | This page contains details on **** commands. 5 | 6 | Connect-ALsession 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Connect-ALsession 12 | 13 | SYNOPSIS 14 | Connects to the Citrix Application Layering appliance and creates a web request session 15 | 16 | 17 | SYNTAX 18 | Connect-ALsession [-Credential] [-aplip] [] 19 | 20 | 21 | DESCRIPTION 22 | Connects to the Citrix Application Layering appliance and creates a web request session 23 | 24 | 25 | PARAMETERS 26 | -Credential 27 | PowerShell credential object 28 | 29 | -aplip 30 | 31 | 32 | This cmdlet supports the common parameters: Verbose, Debug, 33 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 34 | OutBuffer, PipelineVariable, and OutVariable. For more information, see 35 | about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 36 | 37 | -------------------------- EXAMPLE 1 -------------------------- 38 | 39 | PS C:\>$websession = Connect-alsession -aplip $aplip -Credential $Credential -Verbose 40 | 41 | 42 | 43 | 44 | 45 | 46 | REMARKS 47 | To see the examples, type: "get-help Connect-ALsession -examples". 48 | For more information, type: "get-help Connect-ALsession -detailed". 49 | For technical information, type: "get-help Connect-ALsession -full". 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/cmd/cmd_stop.rst: -------------------------------------------------------------------------------- 1 | Commands 2 | ========================= 3 | 4 | This page contains details on **** commands. 5 | 6 | Stop-ALWorkTicket 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Stop-ALWorkTicket 12 | 13 | SYNOPSIS 14 | Stops or cancels a running layer operation process 15 | 16 | 17 | SYNTAX 18 | Stop-ALWorkTicket [-websession] [-id] [-WhatIf] [-Confirm] [] 19 | 20 | 21 | DESCRIPTION 22 | Stops or cancels a running layer operation process 23 | 24 | 25 | PARAMETERS 26 | -websession 27 | Existing Webrequest session for ELM Appliance 28 | 29 | -id 30 | 31 | -WhatIf [] 32 | 33 | -Confirm [] 34 | 35 | 36 | This cmdlet supports the common parameters: Verbose, Debug, 37 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 38 | OutBuffer, PipelineVariable, and OutVariable. For more information, see 39 | about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 40 | 41 | -------------------------- EXAMPLE 1 -------------------------- 42 | 43 | PS C:\>Stop-ALWorkTicket -websession $websession 44 | 45 | 46 | 47 | 48 | 49 | 50 | REMARKS 51 | To see the examples, type: "get-help Stop-ALWorkTicket -examples". 52 | For more information, type: "get-help Stop-ALWorkTicket -detailed". 53 | For technical information, type: "get-help Stop-ALWorkTicket -full". 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alCachePointInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALCachePointInfo { 2 | <# 3 | .SYNOPSIS 4 | Gets appliance Layering Service Info 5 | .DESCRIPTION 6 | Gets appliance Layering Service Info 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALCachePointInfo -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | "@ 28 | Write-Verbose $xml 29 | $headers = @{ 30 | SOAPAction = "http://www.unidesk.com/QueryCachePoints"; 31 | "Content-Type" = "text/xml; charset=utf-8"; 32 | UNIDESK_TOKEN = $websession.token; 33 | } 34 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 35 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 36 | [xml]$obj = $return.Content 37 | 38 | if ($obj.Envelope.Body.QueryCachePointsResponse.QueryCachePointsResult.Error) { 39 | throw $obj.Envelope.Body.QueryCachePointsResponse.QueryCachePointsResult.Error.message 40 | } 41 | else { 42 | return $obj.Envelope.Body.QueryCachePointsResponse.QueryCachePointsResult.CachePointResults.CachePointSummary 43 | } 44 | } 45 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 46 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alicon.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALicon { 2 | <# 3 | .SYNOPSIS 4 | Gets all icon IDs 5 | .DESCRIPTION 6 | Gets all icon IDs 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALicon -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | "@ 30 | Write-Verbose $xml 31 | $headers = @{ 32 | SOAPAction = "http://www.unidesk.com/QueryLayerIcons"; 33 | "Content-Type" = "text/xml; charset=utf-8"; 34 | UNIDESK_TOKEN = $websession.token; 35 | } 36 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 37 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 38 | [xml]$obj = $return.Content 39 | 40 | $final = @() 41 | foreach ($iconid in $obj.Envelope.Body.QueryLayerIconsResponse.QueryLayerIconsResult.IconIds.long) { 42 | $final += [PSCustomObject]@{ 43 | ICONID = $iconid 44 | URL = "https://$($websession.aplip)/Unidesk.Web/GetImage.ashx?id=$iconid" 45 | } 46 | 47 | } 48 | 49 | return $final 50 | } 51 | 52 | 53 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 54 | } 55 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aliconassoc.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALiconassoc { 2 | <# 3 | .SYNOPSIS 4 | Gets items associated with icon 5 | .DESCRIPTION 6 | Gets items associated with icon 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER iconid 10 | Icon ID 11 | .EXAMPLE 12 | Get-ALicon -websession $websession 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$iconid 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $iconid 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/GetItemsAssociatedWithIcon"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 42 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 43 | [xml]$obj = $return.Content 44 | 45 | 46 | return $obj.Envelope.Body.GetItemsAssociatedWithIconResponse.GetItemsAssociatedWithIconResult.Items.ItemsAssociatedWithIconDto 47 | } 48 | 49 | 50 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 51 | } 52 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/stop-alworkticket.ps1: -------------------------------------------------------------------------------- 1 | function Stop-ALWorkTicket { 2 | <# 3 | .SYNOPSIS 4 | Stops or cancels a running layer operation process 5 | .DESCRIPTION 6 | Stops or cancels a running layer operation process 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Stop-ALWorkTicket -websession $websession 11 | #> 12 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession, 15 | [Parameter(Mandatory = $true)][string]$id 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | Test-ALWebsession -WebSession $websession 20 | } 21 | Process { 22 | [xml]$xml = @" 23 | 24 | 25 | 26 | 27 | 28 | $id 29 | 30 | false 31 | 32 | 33 | 34 | 35 | "@ 36 | Write-Verbose $xml 37 | $headers = @{ 38 | SOAPAction = "http://www.unidesk.com/CancelWorkTickets"; 39 | "Content-Type" = "text/xml; charset=utf-8"; 40 | UNIDESK_TOKEN = $websession.token; 41 | } 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | if ($PSCmdlet.ShouldProcess("Remove Work ID $id")) { 44 | Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession | Out-Null 45 | } 46 | } 47 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 48 | } 49 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-AlLocalUser.ps1: -------------------------------------------------------------------------------- 1 | Function Get-ALLocalUser { 2 | <# 3 | .SYNOPSIS 4 | Gets ELM local users 5 | .DESCRIPTION 6 | Gets ELM local users 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALLocalUser -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | Test-ALWebsession -WebSession $websession 20 | } 21 | 22 | Process { 23 | [xml]$xml = @" 24 | 25 | 26 | 27 | 28 | All 29 | 30 | 31 | 32 | 33 | "@ 34 | Write-Verbose $xml 35 | $headers = @{ 36 | SOAPAction = "http://www.unidesk.com/QueryUsers"; 37 | "Content-Type" = "text/xml; charset=utf-8"; 38 | UNIDESK_TOKEN = $websession.token; 39 | } 40 | 41 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 42 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 43 | [xml]$obj = $return.Content 44 | 45 | 46 | if ($obj.Envelope.Body.QueryUsersResponse.QueryUsersResult.Users.Error) { 47 | throw $obj.Envelope.Body.QueryUsersResponse.QueryUsersResult.Users.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.body.QueryUsersResponse.QueryUsersResult.Users.UserSummary 51 | } 52 | } 53 | 54 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 55 | 56 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alicon.ps1: -------------------------------------------------------------------------------- 1 | function remove-ALicon { 2 | <# 3 | .SYNOPSIS 4 | Removes icon based on ID 5 | .DESCRIPTION 6 | Removes icon based on ID 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER iconid 10 | Icon ID 11 | .EXAMPLE 12 | Remove-ALicon -websession $websession -iconid "4259847" 13 | #> 14 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$iconid 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $iconid 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/DeleteIcon"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 42 | if ($PSCmdlet.ShouldProcess("Removing ICONID $iconid")) { 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | return $obj.Envelope.Body.DeleteIconResponse.DeleteIconResult.ErrorCode 46 | } 47 | 48 | } 49 | 50 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 51 | } 52 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alimage.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALimage { 2 | <# 3 | .SYNOPSIS 4 | Gets all images(templates) 5 | .DESCRIPTION 6 | Gets all images(templates) 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALimage -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | "@ 32 | Write-Verbose $xml 33 | $headers = @{ 34 | SOAPAction = "http://www.unidesk.com/QueryImageSummary"; 35 | "Content-Type" = "text/xml; charset=utf-8"; 36 | UNIDESK_TOKEN = $websession.token; 37 | } 38 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 39 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 40 | [xml]$obj = $return.Content 41 | 42 | if ($obj.Envelope.Body.QueryImageSummaryResponse.QueryImageSummaryResult.Error) { 43 | throw $obj.Envelope.Body.QueryImageSummaryResponse.QueryImageSummaryResult.Error.message 44 | } 45 | else { 46 | return $obj.Envelope.Body.QueryImageSummaryResponse.QueryImageSummaryResult.Images.ImageEntitySummary 47 | } 48 | } 49 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 50 | } 51 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aloslayer.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALOsLayer { 2 | <# 3 | .SYNOPSIS 4 | Gets all OS layers 5 | .DESCRIPTION 6 | Gets all OS layers 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALOsLayer -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 0 27 | 28 | 29 | 30 | 31 | 32 | "@ 33 | Write-Verbose $xml 34 | $headers = @{ 35 | SOAPAction = "http://www.unidesk.com/QueryOsLayers"; 36 | "Content-Type" = "text/xml; charset=utf-8"; 37 | UNIDESK_TOKEN = $websession.token; 38 | } 39 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 40 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 41 | [xml]$obj = $return.Content 42 | 43 | 44 | if ($obj.Envelope.Body.QueryOsLayersResponse.QueryOsLayersResult.OsLayers.Error) { 45 | throw $obj.Envelope.Body.QueryOsLayersResponse.QueryOsLayersResult.OsLayers.Error.message 46 | } 47 | else { 48 | return $obj.Envelope.Body.QueryOsLayersResponse.QueryOsLayersResult.OsLayers.LayerEntitySummary 49 | } 50 | } 51 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 52 | } 53 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alSystemsettingInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALSystemSettingInfo { 2 | <# 3 | .SYNOPSIS 4 | Gets appliance System Settings 5 | .DESCRIPTION 6 | Gets appliance System Settings 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALSystemSettingInfo -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | "@ 31 | Write-Verbose $xml 32 | $headers = @{ 33 | SOAPAction = "http://www.unidesk.com/QuerySystemSettings"; 34 | "Content-Type" = "text/xml; charset=utf-8"; 35 | UNIDESK_TOKEN = $websession.token; 36 | } 37 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 38 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 39 | [xml]$obj = $return.Content 40 | 41 | if ($obj.Envelope.Body.QuerySystemSettingsResponse.QuerySystemSettingsResult.Error) { 42 | throw $obj.Envelope.Body.QuerySystemSettingsResponse.QuerySystemSettingsResult.Error.message 43 | } 44 | else { 45 | return $obj.Envelope.Body.QuerySystemSettingsResponse.QuerySystemSettingsResult.Settings.SysSetting 46 | } 47 | } 48 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 49 | } 50 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alDirectoryDetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALDirectoryDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets additional directory junction detail 5 | .DESCRIPTION 6 | Gets additional directory junction detail 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Directory Junction id 11 | .EXAMPLE 12 | get-aldirectorydetail -websession $websession -id $directory.id 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | 30 | $id 31 | 32 | 33 | 34 | 35 | 36 | "@ 37 | Write-Verbose $xml 38 | $headers = @{ 39 | SOAPAction = "http://www.unidesk.com/QueryDirectoryJunctionDetails"; 40 | "Content-Type" = "text/xml; charset=utf-8"; 41 | UNIDESK_TOKEN = $websession.token; 42 | } 43 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 44 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 45 | [xml]$obj = $return.Content 46 | 47 | return $obj.Envelope.Body.QueryDirectoryJunctionDetailsResponse.QueryDirectoryJunctionDetailsResult.Details.DirectoryJunctionDetails 48 | 49 | } 50 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 51 | } 52 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alremoteshare.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALRemoteshare { 2 | <# 3 | .SYNOPSIS 4 | Gets CIFS share information currently configured 5 | .DESCRIPTION 6 | Gets CIFS share information currently configured 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALRemoteshare -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | "@ 30 | Write-Verbose $xml 31 | $headers = @{ 32 | SOAPAction = "http://www.unidesk.com/QueryRemoteFileShares"; 33 | "Content-Type" = "text/xml; charset=utf-8"; 34 | UNIDESK_TOKEN = $websession.token; 35 | } 36 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 37 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 38 | [xml]$obj = $return.Content 39 | 40 | 41 | if ($obj.Envelope.Body.QueryRemoteFileSharesResponse.QueryRemoteFileSharesResult.Error) { 42 | throw $obj.Envelope.Body.QueryRemoteFileSharesResponse.QueryRemoteFileSharesResult.Error.message 43 | } 44 | else { 45 | return $obj.Envelope.Body.QueryRemoteFileSharesResponse.QueryRemoteFileSharesResult.RemoteShares.RemoteFileShareSummary 46 | } 47 | } 48 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 49 | } -------------------------------------------------------------------------------- /docs/use/use_directoryjunction.md: -------------------------------------------------------------------------------- 1 | # Directory Junction 2 | 3 | ## New Directory Junction 4 | 5 | ```powershell 6 | new-aldirectory -websession $websession -serveraddress "mydc.domain.com" -usessl -username "admin@domain.com" -adpassword "MYPASSWORD" -basedn DC=domain,DC=com -name "Mydirectory" 7 | ``` 8 | 9 | ## Get ALL Directory Junctions 10 | 11 | ```powershell 12 | Get-ALDirectory -websession $websession 13 | ``` 14 | 15 | ## Get Directory Junction Info 16 | 17 | ```powershell 18 | get-aldirectorydetail -websession $websession -id $directory.id 19 | ``` 20 | 21 | ## Set Directory Junction Info 22 | 23 | ```powershell 24 | Set-aldirectory -websession $websession -adpassword "MYPASSWORD" -id $directory.id -name "MYNEWNAME" 25 | ``` 26 | 27 | ## Delete Directory Junction 28 | 29 | ```powershell 30 | Remove-ALDirectory -websession $websession -id "4915204" 31 | ``` 32 | 33 | ## User Info 34 | 35 | ```powershell 36 | $dir = Get-ALDirectory -websession $websession|where{$_.name -eq "MyDirectory"} 37 | $userid = Get-ALUserList -websession $websession -junctionid $dir.id -dn "CN=Users,DC=mydomain,DC=com"|Where-Object {$_.loginname -eq "myusername"} 38 | $userdetail = Get-ALUserDetail -websession $websession -junctionid $dir.id -ldapguid $userid.DirectoryId.LdapGuid -dn $userid.DirectoryId.LdapDN -id $userid.DirectoryId.UnideskId 39 | $groups = Get-ALUserGroupMembership -websession $websession -junctionid $dir.id -id $User.DirectoryId.UnideskId -ldapguid $user.FullId.LdapGuid -ldapdn $user.FullId.LdapDN -sid $userdetail.FullId.sid 40 | #build group array for search 41 | $groupids = @() 42 | $groups|%{$groupids += $_.DirectoryId.UnideskId} 43 | #add user to group array 44 | $groupids += $User.DirectoryId.UnideskId 45 | $apps = Get-ALUserAssignment -websession $websession -id $userid.DirectoryId.UnideskId -Verbose 46 | $apps|Select-Object LayerName,CurrentRevision,PendingRevision,AssignedViaDisplayName 47 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alplatformlayer.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALPlatformlayer { 2 | <# 3 | .SYNOPSIS 4 | Gets all platform layers 5 | .DESCRIPTION 6 | Gets all platform layers 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALPlatformlayer -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 0 27 | 28 | 29 | 30 | 31 | 32 | "@ 33 | Write-Verbose $xml 34 | $headers = @{ 35 | SOAPAction = "http://www.unidesk.com/QueryPlatformLayers"; 36 | "Content-Type" = "text/xml; charset=utf-8"; 37 | UNIDESK_TOKEN = $websession.token; 38 | } 39 | 40 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 41 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 42 | [xml]$obj = $return.Content 43 | 44 | if ($obj.Envelope.Body.QueryPlatformLayersResponse.QueryPlatformLayersResult.Error) { 45 | throw $obj.Envelope.Body.QueryPlatformLayersResponse.QueryPlatformLayersResult.Error.message 46 | } 47 | else { 48 | return $obj.Envelope.Body.QueryPlatformLayersResponse.QueryPlatformLayersResult.PlatformLayers.LayerEntitySummary 49 | } 50 | } 51 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 52 | } 53 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alapplayer.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALapplayer { 2 | <# 3 | .SYNOPSIS 4 | Gets all application layers 5 | .DESCRIPTION 6 | Gets all application layers 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALapplayer -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 0 27 | 28 | 29 | 30 | 31 | 32 | "@ 33 | Write-Verbose $xml 34 | $headers = @{ 35 | SOAPAction = "http://www.unidesk.com/QueryApplicationLayers"; 36 | "Content-Type" = "text/xml; charset=utf-8"; 37 | UNIDESK_TOKEN = $websession.token; 38 | } 39 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 40 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 41 | [xml]$obj = $return.Content 42 | 43 | 44 | if ($obj.Envelope.Body.QueryApplicationLayersResponse.QueryApplicationLayersResult.Error) { 45 | throw $obj.Envelope.Body.QueryApplicationLayersResponse.QueryApplicationLayersResult.Error.message 46 | } 47 | else { 48 | return $obj.Envelope.Body.QueryApplicationLayersResponse.QueryApplicationLayersResult.AppLayers.LayerEntitySummary 49 | } 50 | } 51 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 52 | } -------------------------------------------------------------------------------- /docs/cmd/cmd_export.rst: -------------------------------------------------------------------------------- 1 | Commands 2 | ========================= 3 | 4 | This page contains details on **** commands. 5 | 6 | Export-ALLayerRev 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Export-ALLayerRev 12 | 13 | SYNOPSIS 14 | Gets revisions that can be used to export 15 | 16 | 17 | SYNTAX 18 | Export-ALLayerRev [-websession] [-sharepath] [-id] [[-username] ] [[-sharepw] ] [] 19 | 20 | 21 | DESCRIPTION 22 | Gets revisions that can be used to export 23 | 24 | 25 | PARAMETERS 26 | -websession 27 | Existing Webrequest session for ELM Appliance 28 | 29 | -sharepath 30 | Share UNC Path type 31 | 32 | -id 33 | ID(s) of revision layers to export 34 | 35 | -username 36 | Share username 37 | 38 | -sharepw 39 | Share password 40 | 41 | 42 | This cmdlet supports the common parameters: Verbose, Debug, 43 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 44 | OutBuffer, PipelineVariable, and OutVariable. For more information, see 45 | about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 46 | 47 | -------------------------- EXAMPLE 1 -------------------------- 48 | 49 | PS C:\>Export-ALlayerrev -websession $websession -sharepath "\\myserver\path\layers" -id @(12042,225252,2412412) 50 | 51 | 52 | 53 | 54 | 55 | 56 | REMARKS 57 | To see the examples, type: "get-help Export-ALLayerRev -examples". 58 | For more information, type: "get-help Export-ALLayerRev -detailed". 59 | For technical information, type: "get-help Export-ALLayerRev -full". 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-ALPendingOp.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALPendingOp { 2 | <# 3 | .SYNOPSIS 4 | Gets appliance operation based on ID 5 | .DESCRIPTION 6 | Gets appliance operation based on ID 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | workticket id 11 | .EXAMPLE 12 | Get-ALPendingOp -websession $websession -id $myworkid 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $id 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/QueryPendingOperation"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryPendingOperationResponse.QueryPendingOperationResult.Error) { 47 | throw $obj.Envelope.Body.QueryPendingOperationResponse.QueryPendingOperationResult.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.Body.QueryPendingOperationResponse.QueryPendingOperationResult 51 | } 52 | } 53 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 54 | } 55 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alimageDetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALimageDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets additional image(template) detail 5 | .DESCRIPTION 6 | Gets additional image(template) detail 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Image(template) id 11 | .EXAMPLE 12 | get-alimagedetail -websession $websession -id $image.id 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | 30 | $id 31 | 32 | 33 | 34 | 35 | 36 | "@ 37 | Write-Verbose $xml 38 | $headers = @{ 39 | SOAPAction = "http://www.unidesk.com/QueryImageDetail"; 40 | "Content-Type" = "text/xml; charset=utf-8"; 41 | UNIDESK_TOKEN = $websession.token; 42 | } 43 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 44 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 45 | [xml]$obj = $return.Content 46 | 47 | 48 | if ($obj.Envelope.Body.QueryImageDetailResponse.QueryImageDetailResult.Error) { 49 | throw $obj.Envelope.Body.QueryImageDetailResponse.QueryImageDetailResult.Error.message 50 | } 51 | else { 52 | return $obj.Envelope.Body.QueryImageDetailResponse.QueryImageDetailResult.Images.ImageDetail 53 | } 54 | } 55 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 56 | } 57 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alconnectortype.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALconnectortype { 2 | <# 3 | .SYNOPSIS 4 | Gets all Connector Types 5 | .DESCRIPTION 6 | Gets all Connector Types 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER name 10 | Name of object to return 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession, 15 | [Parameter(Mandatory = $false)][SupportsWildcards()][string]$name = "*" 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | Test-ALWebsession -WebSession $websession 20 | } 21 | Process { 22 | [xml]$xml = @" 23 | 24 | 25 | 26 | 27 | None 28 | 29 | 30 | 31 | 32 | "@ 33 | Write-Verbose $xml 34 | $headers = @{ 35 | SOAPAction = "http://www.unidesk.com/QueryPlatformConnectors"; 36 | "Content-Type" = "text/xml; charset=utf-8"; 37 | UNIDESK_TOKEN = $websession.token; 38 | } 39 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 40 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 41 | [xml]$obj = $return.Content 42 | 43 | 44 | if ($obj.Envelope.Body.QueryPlatformConnectorsResponse.QueryPlatformConnectorsResult.Error) { 45 | throw $obj.Envelope.Body.QueryPlatformConnectorsResponse.QueryPlatformConnectorsResult.Error.message 46 | } 47 | else { 48 | return $obj.Envelope.Body.QueryPlatformConnectorsResponse.QueryPlatformConnectorsResult.Connectors.PlatformConnectorDetails | Where-Object { $_.name -like $name } 49 | } 50 | } 51 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 52 | } 53 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aloslayerdetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALOsLayerDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets detailed information on a OS layer including revisions 5 | .DESCRIPTION 6 | Gets detailed information on a OS layer including revisions 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Operating System Layer ID 11 | .EXAMPLE 12 | get-aloslayerdetail -websession $websession -id $app.AssociatedOsLayerId 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $id 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/QueryOsLayerDetails"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryOsLayerDetailsResponse.QueryOsLayerDetailsResult.Error) { 47 | throw $obj.Envelope.Body.QueryOsLayerDetailsResponse.QueryOsLayerDetailsResult.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.Body.QueryOsLayerDetailsResponse.QueryOsLayerDetailsResult 51 | } 52 | } 53 | 54 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 55 | } 56 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alSysteminfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALSystemInfo { 2 | <# 3 | .SYNOPSIS 4 | Gets appliance System Details 5 | .DESCRIPTION 6 | Gets appliance System Details 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALSystemInfo -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | false 27 | 28 | 29 | 30 | 31 | "@ 32 | Write-Verbose $xml 33 | $headers = @{ 34 | SOAPAction = "http://www.unidesk.com/QueryManagementApplianceDetailsWithParam"; 35 | "Content-Type" = "text/xml; charset=utf-8"; 36 | UNIDESK_TOKEN = $websession.token; 37 | } 38 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 39 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 40 | [xml]$obj = $return.Content 41 | 42 | if ($obj.Envelope.Body.QueryManagementApplianceDetailsWithParamResponse.QueryManagementApplianceDetailsWithParamResult.Error) { 43 | throw $obj.Envelope.Body.QueryManagementApplianceDetailsWithParamResponse.QueryManagementApplianceDetailsWithParamResult.Error.message 44 | } 45 | else { 46 | return $obj.Envelope.Body.QueryManagementApplianceDetailsWithParamResponse.QueryManagementApplianceDetailsWithParamResult 47 | } 48 | } 49 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 50 | } 51 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-allayerinstalldisk.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALLayerInstallDisk { 2 | <# 3 | .SYNOPSIS 4 | Gets install disk location during finalize process 5 | .DESCRIPTION 6 | Gets install disk location during finalize process 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Layer ID to be located 11 | .EXAMPLE 12 | get-allayerinstalldisk -websession $websession -layerid $apprevid.LayerId 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | 19 | ) 20 | Begin { 21 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 22 | Test-ALWebsession -WebSession $websession 23 | } 24 | Process { 25 | [xml]$xml = @" 26 | 27 | 28 | 29 | 30 | $id 31 | 32 | 33 | 34 | 35 | "@ 36 | Write-Verbose $xml 37 | $headers = @{ 38 | SOAPAction = "http://www.unidesk.com/QueryLayerInstallDisk"; 39 | "Content-Type" = "text/xml; charset=utf-8"; 40 | UNIDESK_TOKEN = $websession.token; 41 | } 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryLayerInstallDiskResponse.QueryLayerInstallDiskResult.Error) { 47 | throw $obj.Envelope.Body.QueryLayerInstallDiskResponse.QueryLayerInstallDiskResult.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.Body.QueryLayerInstallDiskResponse.QueryLayerInstallDiskResult 51 | } 52 | 53 | } 54 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 55 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alstatus.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALStatus { 2 | <# 3 | .SYNOPSIS 4 | Gets any non-completed task currently running on appliance 5 | .DESCRIPTION 6 | Gets any non-completed task currently running on appliance 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Workticket ID of job 11 | .EXAMPLE 12 | Get-ALStatus -websession $websession 13 | .EXAMPLE 14 | Get-ALStatus -websession $websession -id "4521984" 15 | #> 16 | [cmdletbinding()] 17 | Param( 18 | [Parameter(Mandatory = $true)]$websession, 19 | [Parameter(Mandatory = $false)][SupportsWildcards()][string]$id = "*" 20 | ) 21 | Begin { 22 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 23 | Test-ALWebsession -WebSession $websession 24 | } 25 | Process { 26 | [xml]$xml = @" 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | "@ 36 | Write-Verbose $xml 37 | $headers = @{ 38 | SOAPAction = "http://www.unidesk.com/QueryActivity"; 39 | "Content-Type" = "text/xml; charset=utf-8"; 40 | UNIDESK_TOKEN = $websession.token; 41 | } 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryActivityResponse.QueryActivityResult.Error) { 47 | throw $obj.Envelope.Body.QueryActivityResponse.QueryActivityResult.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.Body.QueryActivityResponse.QueryActivityResult.Events.WorkTicketUpdatedEvent.Result.WorkTickets.WorkTicketResult | Where-Object { $_.id -like $id } 51 | } 52 | } 53 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 54 | } 55 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alplatformlayerDetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALPlatformLayerDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets detailed information on a platform layer including revisions 5 | .DESCRIPTION 6 | Gets detailed information on a platform layer including revisions 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Platform layer ID 11 | .EXAMPLE 12 | get-alplatformlayerDetail -websession $websession -id $platform.id 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $id 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/QueryPlatformLayerDetails"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryPlatformLayerDetailsResponse.QueryPlatformLayerDetailsResult.Error) { 47 | throw $obj.Envelope.Body.QueryPlatformLayerDetailsResponse.QueryPlatformLayerDetailsResult.Error.message 48 | } 49 | else { 50 | return $obj.Envelope.Body.QueryPlatformLayerDetailsResponse.QueryPlatformLayerDetailsResult 51 | } 52 | } 53 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 54 | } 55 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alapplayerdetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALapplayerDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets detailed information on Application Layer including revisions(versions) 5 | .DESCRIPTION 6 | Gets detailed information on Application Layer including revisions(versions) 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Application layer ID 11 | .EXAMPLE 12 | get-alapplayer -websession $websession -id $app.Id 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $id 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/QueryApplicationLayerDetails"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | } 41 | 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 44 | [xml]$obj = $return.Content 45 | 46 | if ($obj.Envelope.Body.QueryApplicationLayerDetailsResponse.QueryApplicationLayerDetailsResult.Error) { 47 | throw $obj.Envelope.Body.QueryApplicationLayerDetailsResponse.QueryApplicationLayerDetailsResult.Error.message 48 | 49 | } 50 | else { 51 | return $obj.Envelope.Body.QueryApplicationLayerDetailsResponse.QueryApplicationLayerDetailsResult 52 | } 53 | } 54 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 55 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alconnector.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALConnector { 2 | <# 3 | .SYNOPSIS 4 | Removes Connector 5 | .DESCRIPTION 6 | Removes Connector 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER connid 10 | Connector ID 11 | .EXAMPLE 12 | Remove-ALConnector -websession $websession -connid $conn.Id 13 | #> 14 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)]$connid 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | $connid 30 | 31 | 32 | 33 | 34 | "@ 35 | Write-Verbose $xml 36 | $headers = @{ 37 | SOAPAction = "http://www.unidesk.com/DeletePlatformConnectorConfiguration"; 38 | "Content-Type" = "text/xml; charset=utf-8"; 39 | UNIDESK_TOKEN = $websession.token; 40 | 41 | } 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | if ($PSCmdlet.ShouldProcess("Removing $connid")) { 44 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 45 | [xml]$obj = $return.Content 46 | 47 | if ($obj.Envelope.Body.DeletePlatformConnectorConfigurationResponse.DeletePlatformConnectorConfigurationResult.Error) { 48 | throw $obj.Envelope.Body.DeletePlatformConnectorConfigurationResponse.DeletePlatformConnectorConfigurationResult.Error.message 49 | 50 | } 51 | else { 52 | write-verbose "$connid removed" 53 | } 54 | } 55 | 56 | } 57 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 58 | } 59 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Remove-ALImage.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALImage { 2 | <# 3 | .SYNOPSIS 4 | Removes image(template) 5 | .DESCRIPTION 6 | Removes image(template) 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | ID of image to remove 11 | .EXAMPLE 12 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Windows 10 Accounting"} 13 | Remove-ALImage -websession $websession -imageid $image.id 14 | #> 15 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 16 | Param( 17 | [Parameter(Mandatory = $true)]$websession, 18 | [Parameter(Mandatory = $true)][string]$id 19 | ) 20 | Begin { 21 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 22 | Test-ALWebsession -WebSession $websession 23 | } 24 | Process { 25 | [xml]$xml = @" 26 | 27 | 28 | 29 | 30 | 31 | $id 32 | 33 | 34 | 0 35 | 36 | 37 | 38 | 39 | 40 | "@ 41 | Write-Verbose $xml 42 | $headers = @{ 43 | SOAPAction = "http://www.unidesk.com/DeleteImage"; 44 | "Content-Type" = "text/xml; charset=utf-8"; 45 | UNIDESK_TOKEN = $websession.token; 46 | } 47 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 48 | if ($PSCmdlet.ShouldProcess("Deleting image $imageid")) { 49 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 50 | [xml]$obj = $return.Content 51 | 52 | 53 | if ($obj.Envelope.Body.DeleteImageResponse.DeleteImageResult.Error) { 54 | throw $obj.Envelope.Body.DeleteImageResponse.DeleteImageResult.Error.ExceptionMessage 55 | 56 | } 57 | else { 58 | return $obj.Envelope.Body.DeleteImageResponse.DeleteImageResult 59 | } 60 | } 61 | } 62 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 63 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/New-ALImageClone.ps1: -------------------------------------------------------------------------------- 1 | function New-ALImageClone { 2 | <# 3 | .SYNOPSIS 4 | Clones an Image 5 | .DESCRIPTION 6 | Clones an Image 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER imageid 10 | id for the image to be cloned 11 | .EXAMPLE 12 | $image = Get-ALimage -websession $websession | where {$_.name -eq "Windows 10 Accounting"} 13 | New-ALImageClone -websession $websession -imageid $image.Id -Confirm:$false -OutVariable ALImageClone 14 | #> 15 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 16 | Param( 17 | [Parameter(Mandatory = $true)]$websession, 18 | [Parameter(Mandatory = $true)]$imageid 19 | ) 20 | Begin { 21 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 22 | Test-ALWebsession -WebSession $websession 23 | } 24 | Process { 25 | [xml]$xml = @" 26 | 27 | 28 | 29 | 30 | $imageid 31 | 32 | 33 | 34 | 35 | "@ 36 | Write-Verbose $xml 37 | $headers = @{ 38 | SOAPAction = "http://www.unidesk.com/CloneImage"; 39 | "Content-Type" = "text/xml; charset=utf-8"; 40 | UNIDESK_TOKEN = $websession.token; 41 | } 42 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 43 | if ($PSCmdlet.ShouldProcess("Clone Image $imageid")) { 44 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 45 | [xml]$obj = $return.Content 46 | 47 | if ($obj.Envelope.Body.CloneImageResponse.CloneImageResult.Error) { 48 | throw $obj.Envelope.Body.CloneImageResponse.CloneImageResult.Error.message 49 | 50 | } 51 | else { 52 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.CloneImageResponse.CloneImageResult.WorkTicketId)" 53 | return $obj.Envelope.Body.CloneImageResponse.CloneImageResult 54 | } 55 | } 56 | 57 | } 58 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 59 | } 60 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-aldirectory.ps1: -------------------------------------------------------------------------------- 1 | function remove-ALDirectory { 2 | <# 3 | .SYNOPSIS 4 | Removes Directory Junction 5 | .DESCRIPTION 6 | Removes Directory Junction 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER ID 10 | Directory Junction ID 11 | .EXAMPLE 12 | Remove-ALDirectory -websession $websession -id "4915204" 13 | #> 14 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | [xml]$xml = @" 25 | 26 | 27 | 28 | 29 | 30 | $id 31 | 32 | 33 | 0 34 | 35 | 36 | 37 | 38 | 39 | "@ 40 | Write-Verbose $xml 41 | $headers = @{ 42 | SOAPAction = "http://www.unidesk.com/DeleteDirectoryJunction"; 43 | "Content-Type" = "text/xml; charset=utf-8"; 44 | UNIDESK_TOKEN = $websession.token; 45 | } 46 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 47 | if ($PSCmdlet.ShouldProcess("Removing Directory Junction $id")) { 48 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 49 | [xml]$obj = $return.Content 50 | 51 | if ($obj.Envelope.Body.DeleteDirectoryJunctionResponse.DeleteDirectoryJunctionResult.WorkTicketId -eq "0") { 52 | throw "Problem deleting AD junction. Check ID and try again." 53 | } 54 | else { 55 | return $obj.Envelope.Body.DeleteDirectoryJunctionResponse.DeleteDirectoryJunctionResult.WorkTicketId 56 | } 57 | } 58 | 59 | } 60 | 61 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 62 | } 63 | -------------------------------------------------------------------------------- /docs/use/use_appassignments.md: -------------------------------------------------------------------------------- 1 | # Application Assignments 2 | 3 | ## Add app layers to an image 4 | 5 | ```powershell 6 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Accounting"} 7 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 8 | $apprevs = get-alapplayerDetail -websession $websession -id $app.Id 9 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 10 | add-alappassignment -websession $websession -apprevid $apprevid.id -imageid $image.id 11 | ``` 12 | 13 | ## Remove app layers from an image 14 | 15 | ```powershell 16 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Accounting"} 17 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 18 | $apprevs = Get-ALapplayerDetail -websession $websession -id $app.Id 19 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 20 | remove-alappassignment -websession $websession -applayerid $apprevid.LayerId -imageid $image.id 21 | ``` 22 | 23 | ## Add user\group to Elastic Layers 24 | 25 | ```powershell 26 | $users = @('MyGroup1','MyGroup2','Domain Users') 27 | $finduser = $users|get-alldapobject -websession $websession 28 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 29 | $apprevs = Get-ALapplayerDetail -websession $websession -id $app.Id 30 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 31 | $add = $finduser|add-alelappassignment -websession $websession -apprevid $apprevid.Id 32 | ``` 33 | 34 | ## Remove user\group from Elastic Layers 35 | 36 | ```powershell 37 | $users = @('MyGroup1','MyGroup2','Domain Users') 38 | $finduser = $users|get-alldapobject -websession $websession 39 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 40 | $apprevs = Get-ALapplayerDetail -websession $websession -id $app.Id 41 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 42 | $finduser|remove-alelappassignment -websession $websession -apprevid $apprevid.Id 43 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/Public/invoke-alCreateBundle.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-ALCreateBundle { 2 | <# 3 | .SYNOPSIS 4 | Creates diagnostic bundle 5 | .DESCRIPTION 6 | Creates diagnostic bundle 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Invoke-ALCreateBundle -websession $websession 11 | #> 12 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession, 15 | [switch]$IncludeCrashDumps 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | Test-ALWebsession -WebSession $websession 20 | } 21 | Process { 22 | 23 | if ($IncludeCrashDumps) { 24 | $IncludeCoreFiles = "true" 25 | } 26 | else { 27 | $IncludeCoreFiles = "false" 28 | } 29 | 30 | [xml]$xml = @" 31 | 32 | 33 | 34 | 35 | $includecorefiles 36 | false 37 | 38 | 0 39 | 40 | 41 | 42 | 43 | 44 | "@ 45 | Write-Verbose $xml 46 | $headers = @{ 47 | SOAPAction = "http://www.unidesk.com/GatherDiagnostics"; 48 | "Content-Type" = "text/xml; charset=utf-8"; 49 | UNIDESK_TOKEN = $websession.token; 50 | } 51 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 52 | if ($PSCmdlet.ShouldProcess("Exporting logs")) { 53 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 54 | [xml]$obj = $return.Content 55 | if ($obj.Envelope.Body.GatherDiagnosticsResponse.GatherDiagnosticsResult.Error) { 56 | throw $obj.Envelope.Body.GatherDiagnosticsResponse.GatherDiagnosticsResult.Error.message 57 | } 58 | else { 59 | return $obj.Envelope.Body.GatherDiagnosticsResponse.GatherDiagnosticsResult.WorkTicketId 60 | } 61 | } 62 | 63 | } 64 | 65 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 66 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alconnector.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALconnector { 2 | <# 3 | .SYNOPSIS 4 | Gets all appliance connectors currently configured 5 | .DESCRIPTION 6 | Gets all appliance connectors currently configured 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER type 10 | Connector type for publishing or creating layers\images 11 | .PARAMETER name 12 | Name of object to return 13 | .EXAMPLE 14 | Get-ALconnector -websession $websession -type "Publish" 15 | #> 16 | [cmdletbinding()] 17 | Param( 18 | [Parameter(Mandatory = $true)]$websession, 19 | [Parameter(Mandatory = $true)][ValidateSet("Create", "Publish")][string]$type, 20 | [Parameter(Mandatory = $false)][SupportsWildcards()][string]$name = "*" 21 | ) 22 | Begin { 23 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 24 | Test-ALWebsession -WebSession $websession 25 | } 26 | Process { 27 | [xml]$xml = @" 28 | 29 | 30 | 31 | 32 | $type 33 | 34 | 35 | 36 | 37 | "@ 38 | Write-Verbose $xml 39 | $headers = @{ 40 | SOAPAction = "http://www.unidesk.com/QueryPlatformConnectorConfig"; 41 | "Content-Type" = "text/xml; charset=utf-8"; 42 | UNIDESK_TOKEN = $websession.token; 43 | } 44 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 45 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 46 | [xml]$obj = $return.Content 47 | 48 | 49 | if ($obj.Envelope.Body.QueryPlatformConnectorConfigResponse.QueryPlatformConnectorConfigResult.Error) { 50 | throw $obj.Envelope.Body.QueryPlatformConnectorConfigResponse.QueryPlatformConnectorConfigResult.Error.message 51 | } 52 | else { 53 | return $obj.Envelope.Body.QueryPlatformConnectorConfigResponse.QueryPlatformConnectorConfigResult.Configurations.PlatformConnectorConfig | Where-Object { $_.name -like $name } 54 | } 55 | } 56 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 57 | } 58 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aluserassignment.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALUserAssignment { 2 | <# 3 | .SYNOPSIS 4 | Gets user app layer assignments 5 | .DESCRIPTION 6 | Gets user app layer assignments 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Unidesk ID of user 11 | .EXAMPLE 12 | Get-ALUserAssignments -websession $websession -id "4521984" -Verbose 13 | #> 14 | [cmdletbinding()] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)][string[]]$id 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | $idsxml = $null 23 | } 24 | Process { 25 | 26 | Write-Verbose "Building Group IDs" 27 | foreach ($groupid in $id) { 28 | $idsxml += @" 29 | $groupid 30 | "@ 31 | } 32 | [xml]$xml = @" 33 | 34 | 35 | 36 | 37 | 38 | $idsxml 39 | 40 | 41 | 42 | 43 | 44 | "@ 45 | Write-Verbose $xml 46 | $headers = @{ 47 | SOAPAction = "http://www.unidesk.com/QueryDirectoryItemAppAssignments"; 48 | "Content-Type" = "text/xml; charset=utf-8"; 49 | UNIDESK_TOKEN = $websession.token; 50 | } 51 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 52 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 53 | [xml]$obj = $return.Content 54 | 55 | if ($obj.Envelope.Body.QueryDirectoryItemAppAssignmentsResponse.QueryDirectoryItemAppAssignmentsResult.Error) { 56 | throw $obj.Envelope.Body.QueryDirectoryItemAppAssignmentsResponse.QueryDirectoryItemAppAssignmentsResult.Error.message 57 | } 58 | else { 59 | return $obj.Envelope.Body.QueryDirectoryItemAppAssignmentsResponse.QueryDirectoryItemAppAssignmentsResult.Assignments.DirectoryItemAppAssignment 60 | } 61 | 62 | } 63 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 64 | } 65 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/new-alicon.ps1: -------------------------------------------------------------------------------- 1 | function new-ALicon { 2 | <# 3 | .SYNOPSIS 4 | Converts and uploads image file to be used as icon 5 | .DESCRIPTION 6 | Converts and uploads image file to be used as icon 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER iconfile 10 | Icon filename 11 | .EXAMPLE 12 | Upload-ALicon -websession $websession -iconfilename "d:\mysweeticon.png" 13 | #> 14 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $true)]$iconfile 18 | ) 19 | Begin { 20 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 21 | Test-ALWebsession -WebSession $websession 22 | } 23 | Process { 24 | 25 | if (test-path $iconfile) { 26 | Write-Verbose "$iconfile found!. Converfting to BASE64" 27 | $base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes($iconfile)) 28 | } 29 | else { 30 | throw "File not found!. Pleae check filename and try again!" 31 | } 32 | 33 | [xml]$xml = @" 34 | 35 | 36 | 37 | 38 | $base64string 39 | 40 | Custom icon uploaded. 41 | 0 42 | 43 | 44 | 45 | 46 | 47 | "@ 48 | Write-Verbose $xml 49 | $headers = @{ 50 | SOAPAction = "http://www.unidesk.com/CreateIcon"; 51 | "Content-Type" = "text/xml; charset=utf-8"; 52 | UNIDESK_TOKEN = $websession.token; 53 | } 54 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 55 | 56 | if ($PSCmdlet.ShouldProcess("Will create new ICON from $iconfile")) { 57 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 58 | [xml]$obj = $return.Content 59 | return $obj.Envelope.Body.CreateIconResponse.CreateIconResult.IconId 60 | } 61 | 62 | } 63 | 64 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 65 | } 66 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | os: WMF 5 3 | skip_commits: 4 | files: 5 | - README.md 6 | message: /updated readme.*|update readme.*s|update docs.*|PSGallery Version.*|update appveyor.*/ 7 | only_commits: 8 | files: 9 | - ctxal-sdk/ 10 | pull_requests: 11 | do_not_increment_build_number: true 12 | build_script: 13 | - ps: | 14 | Install-PackageProvider -Name NuGet -Force | Out-Null 15 | find-module -Repository PSGallery -Name PowerShellGet | Out-Null 16 | Install-Module -Name PowerShellGet -Force -Repository PSGallery -SkipPublisherCheck | Out-Null 17 | find-module -Repository PSGallery -Name PSScriptAnalyzer | Out-Null 18 | Install-Module -Name PSScriptAnalyzer -Force -Repository PSGallery -SkipPublisherCheck | Out-Null 19 | find-module -Repository PSGallery -Name Pester | Out-Null 20 | Install-Module -Name Pester -Force -Repository PSGallery -SkipPublisherCheck | Out-Null 21 | find-module -Repository PSGallery -Name PSDeploy | Out-Null 22 | Install-Module -Name PSDeploy -Force -Repository PSGallery -SkipPublisherCheck | Out-Null 23 | find-module -Repository PSGallery -Name posh-git | Out-Null 24 | Install-Module -Name posh-git -Force -Repository PSGallery -SkipPublisherCheck | Out-Null 25 | $env:Path += ";$env:ProgramFiles\Git\cmd" 26 | test_script: 27 | - ps: | 28 | write-verbose "Dot sourcing helper functions" 29 | . .\AppVeyor\helpers.ps1 30 | write-verbose "Running Pester..." 31 | $pest = Invoke-Pester -passthru -verbose 32 | if ($pest.FailedCount -gt 0) { 33 | throw "$($pest.FailedCount) tests failed." 34 | } 35 | deploy_script: 36 | - git config --global credential.helper store 37 | - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:github):x-oauth-basic@github.com`n" 38 | - git config --global user.email "ryan@ryancbutler.com" 39 | - git config --global user.name "Ryan Butler" 40 | - git config --global core.autocrlf false 41 | - git config --global core.safecrlf false 42 | - ps: | 43 | write-verbose "Building Docs..." 44 | . .\AppVeyor\builddocs.ps1 -verbose 45 | Write-Verbose "Deploying..." 46 | . .\AppVeyor\deploy.ps1 -verbose 47 | environment: 48 | PSGKey: 49 | secure: XbgpBX+B+lBgfWt4379Ez1823W4nLM2zPlOWWvw8zGrvKmZD7/uIlpLYrW4zpjMb 50 | github: 51 | secure: qJwCE47jamnSv6Au8wD9CcJmovghdkcm/qoX0IjWa3SDGaeZkGQlQMUlfW9RlsHe -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alvcenterconnector.ps1: -------------------------------------------------------------------------------- 1 | function Get-AlVcenterConnector { 2 | <# 3 | .SYNOPSIS 4 | Gets Vcenter Connector configuration 5 | .DESCRIPTION 6 | Gets Vcenter Connector configuration 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER name 10 | Name of object to return 11 | .PARAMETER includescripts 12 | Include ELM script hosts in return 13 | .EXAMPLE 14 | Get-AlVcenterConnector -websession $websession 15 | #> 16 | [cmdletbinding()] 17 | Param( 18 | [Parameter(Mandatory = $true)]$websession, 19 | [Parameter(Mandatory = $false)][SupportsWildcards()][string]$name = "*", 20 | [Parameter(Mandatory = $false)][switch]$includescripts, 21 | [Parameter(Mandatory = $false)][string]$connid 22 | ) 23 | Begin { Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" } 24 | 25 | Process { 26 | 27 | #do the request 28 | $headers = @{ 29 | "Cookie" = ("UMCSessionCoookie=" + $($websession.token)) 30 | "Accept" = "*/*" 31 | "Content-Type" = "application/json" 32 | "Host" = "$($websession.aplip):3504" 33 | "Referer" = "https://$($websession.aplip):3504/ui/" 34 | } 35 | try { 36 | $url = "https://$($websession.aplip):3504/api/Configurations" 37 | 38 | if ($connid) { 39 | $url = $url + "/$connid" 40 | } 41 | 42 | if ($includescripts) { 43 | $url = $url + "?filter=%7B%22include%22%3A%22scripts%22%7D" 44 | 45 | } 46 | 47 | $content = Invoke-RestMethod -Method Get -Uri $url -Headers $headers 48 | 49 | } 50 | catch { 51 | if ($_.ErrorDetails.Message) { 52 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 53 | if ($temp.message) { 54 | Write-error $temp.message 55 | } 56 | else { 57 | Write-error $temp.error.message 58 | Write-error $temp.error.sqlmessage 59 | write-error $temp.error.staus 60 | } 61 | throw "Process failed!" 62 | } 63 | else { 64 | Write-error $temp.error.message 65 | Write-error $temp.error.sqlmessage 66 | write-error $temp.error.staus 67 | } 68 | } 69 | finally { 70 | 71 | 72 | } 73 | 74 | return $content | Where-Object { $_.pccName -like $name } 75 | } 76 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 77 | } 78 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-ALDirectory.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALDirectory { 2 | <# 3 | .SYNOPSIS 4 | Gets Directory Junctions 5 | .DESCRIPTION 6 | Gets Directory Junctions 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .EXAMPLE 10 | Get-ALDirectory -websession $websession 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [Parameter(Mandatory = $true)]$websession 15 | ) 16 | Begin { 17 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 18 | Test-ALWebsession -WebSession $websession 19 | } 20 | Process { 21 | [xml]$xml = @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | "@ 30 | Write-Verbose $xml 31 | $headers = @{ 32 | SOAPAction = "http://www.unidesk.com/QueryDirectoryJunctionFolders"; 33 | "Content-Type" = "text/xml; charset=utf-8"; 34 | UNIDESK_TOKEN = $websession.token; 35 | } 36 | 37 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 38 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 39 | [xml]$obj = $return.Content 40 | 41 | #apps 42 | 43 | 44 | if ($obj.Envelope.Body.QueryDirectoryJunctionFoldersResponse.QueryDirectoryJunctionFoldersResult.Error) { 45 | throw $obj.Envelope.Body.QueryDirectoryJunctionFoldersResponse.QueryDirectoryJunctionFoldersResult.Error.message 46 | } 47 | else { 48 | $dirs = @() 49 | foreach ($dirobj in $obj.Envelope.Body.QueryDirectoryJunctionFoldersResponse.QueryDirectoryJunctionFoldersResult.DirectoryJunctions.FolderSummary) { 50 | $dir = [PSCustomObject]@{ 51 | NAME = $dirobj.name 52 | ID = $dirobj.DirectoryId.DirectoryJunctionId 53 | LdapDN = $dirobj.DirectoryId.LdapDN 54 | HasImportedChild = $dirobj.HasImportedChild 55 | SubFolderCount = $dirobj.SubFolderCount 56 | GroupCount = $dirobj.GroupCount 57 | UsersCount = $dirobj.UsersCount 58 | } 59 | $dirs += $dir 60 | } 61 | return $dirs 62 | } 63 | } 64 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 65 | } 66 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/set-alvcenterconnector.ps1: -------------------------------------------------------------------------------- 1 | function Set-alVcenterConnector { 2 | <# 3 | .SYNOPSIS 4 | Sets Vcenter Connector configuration 5 | .DESCRIPTION 6 | Sets Vcenter Connector configuration 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER config 10 | Connector Config 11 | .PARAMETER force 12 | Skip Verify 13 | .EXAMPLE 14 | Set-VcenterConnector -websession $websession -config $connectorconfig 15 | #> 16 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 17 | Param( 18 | [Parameter(Mandatory = $true)]$websession, 19 | [Parameter(Mandatory = $true)]$config, 20 | [switch]$force 21 | 22 | ) 23 | Begin { Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" } 24 | 25 | Process { 26 | 27 | #do the request 28 | $headers = @{ 29 | "Cookie" = ("UMCSessionCoookie=" + $($websession.token)) 30 | "Accept" = "*/*" 31 | "Content-Type" = "application/json" 32 | } 33 | 34 | $configjson = $config | ConvertTo-Json -Depth 20 35 | if ($PSCmdlet.ShouldProcess("Setting vCenter Connector")) { 36 | if ($force) { 37 | Write-Verbose "Skipping Connector Data Validation" 38 | } 39 | else { 40 | Write-Verbose "Verifying Connector Data" 41 | try { 42 | Invoke-RestMethod -Method Post -Uri "https://$($websession.aplip):3504/api/Configurations/verify" -Headers $headers -Body $configjson | Out-Null 43 | } 44 | catch { 45 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 46 | Write-error $temp.error.message 47 | Write-error $temp.error.sqlmessage 48 | write-error $temp.error.staus 49 | throw "Process failed!" 50 | } 51 | Write-Verbose "Validation Successful" 52 | } 53 | 54 | try { 55 | Write-Verbose "Setting Connector Data" 56 | Invoke-RestMethod -Method Put -Uri "https://$($websession.aplip):3504/api/Configurations/$($config.pccid)" -Headers $headers -Body $configjson | Out-Null 57 | } 58 | catch { 59 | if ($_.ErrorDetails.Message) { 60 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 61 | Write-error $temp.error.message 62 | Write-error $temp.error.sqlmessage 63 | write-error $temp.error.staus 64 | throw "Process failed!" 65 | } 66 | else { 67 | throw $_ 68 | } 69 | } 70 | 71 | } 72 | } 73 | 74 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alAuditInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALAuditInfo { 2 | <# 3 | .SYNOPSIS 4 | Gets audit information 5 | .DESCRIPTION 6 | Gets System Settings 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER entitytype 10 | Type of log to pull 11 | .PARAMETER ID 12 | ID of entity to pull audit logs 13 | .EXAMPLE 14 | Get-ALAuditInfo -websession $websession -entitytype OsLayer -id 753664 15 | .EXAMPLE 16 | Get-ALAuditInfo -websession $websession -entitytype ManagementAppliance 17 | #> 18 | [cmdletbinding()] 19 | Param( 20 | [Parameter(Mandatory = $true)]$websession, 21 | [Parameter(Mandatory = $true)][ValidateSet("OsLayer", "PlatformLayer", "AppLayer", "Image", "ManagementAppliance")][string]$entitytype, 22 | [Parameter(Mandatory = $false)][string]$id 23 | ) 24 | Begin { 25 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 26 | Test-ALWebsession -WebSession $websession 27 | if ($entitytype -eq "ManagementAppliance") { 28 | $id = "32768" #appliance ID 29 | } 30 | 31 | if ([string]::IsNullOrWhiteSpace($id)) { 32 | throw "Entity ID for $entitytype audit log required" 33 | } 34 | 35 | } 36 | Process { 37 | [xml]$xml = @" 38 | 39 | 40 | 41 | 42 | 0 43 | 250 44 | DateLastModified 45 | true 46 | $entitytype 47 | $id 48 | 49 | 50 | 51 | 52 | "@ 53 | Write-Verbose $xml 54 | $headers = @{ 55 | SOAPAction = "http://www.unidesk.com/QueryAuditLog"; 56 | "Content-Type" = "text/xml; charset=utf-8"; 57 | UNIDESK_TOKEN = $websession.token; 58 | } 59 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 60 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 61 | [xml]$obj = $return.Content 62 | 63 | if ($obj.Envelope.Body.QueryAuditLogResponse.QueryAuditLogResult.Error) { 64 | throw $obj.Envelope.Body.QueryAuditLogResponse.QueryAuditLogResult.Error.message 65 | } 66 | else { 67 | return $obj.Envelope.Body.QueryAuditLogResponse.QueryAuditLogResult.items 68 | } 69 | } 70 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 71 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/Get-ALConnectorDetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALConnectorDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets Detailed Connector configurations 5 | .DESCRIPTION 6 | Gets Detailed Connector configurations 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER connid 10 | connection ID of the specific connector (Use: Get-ALConnector) 11 | .PARAMETER port 12 | port of the specific connector (Use: Get-ALConnector) 13 | .PARAMETER includescripts 14 | Include ELM script hosts in return 15 | .EXAMPLE 16 | get-alconnectordetail -websession $websession -connid $connector.Id -port $connector.ConfigurationSslPort 17 | #> 18 | [cmdletbinding()] 19 | Param( 20 | [Parameter(Mandatory = $true)]$websession, 21 | [Parameter(Mandatory = $false)][SupportsWildcards()][string]$name = "*", 22 | [Parameter(Mandatory = $false)][switch]$includescripts, 23 | [Parameter(Mandatory = $false)][string]$port, 24 | [Parameter(Mandatory = $false)][string]$connid 25 | ) 26 | Begin { Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" } 27 | 28 | Process { 29 | 30 | #do the request 31 | $headers = @{ 32 | "Cookie" = ("UMCSessionCoookie=" + $($websession.token)) 33 | "Accept" = "*/*" 34 | "Content-Type" = "application/json" 35 | "Host" = "$($websession.aplip):$port" 36 | "Referer" = "https://$($websession.aplip):$port/ui/" 37 | } 38 | try { 39 | $url = "https://$($websession.aplip):$port/api/Configurations" 40 | 41 | if ($connid) { 42 | $url = $url + "/$connid" 43 | } 44 | 45 | if ($includescripts) { 46 | $url = $url + "?filter=%7B%22include%22%3A%22scripts%22%7D" 47 | 48 | } 49 | 50 | $content = Invoke-RestMethod -Method Get -Uri $url -WebSession $websession -Headers $headers 51 | 52 | } 53 | catch { 54 | if ($_.ErrorDetails.Message) { 55 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 56 | if ($temp.message) { 57 | Write-error $temp.message 58 | } 59 | else { 60 | Write-error $temp.error.message 61 | Write-error $temp.error.sqlmessage 62 | write-error $temp.error.staus 63 | } 64 | throw "Process failed!" 65 | } 66 | else { 67 | Write-error $temp.error.message 68 | Write-error $temp.error.sqlmessage 69 | write-error $temp.error.staus 70 | } 71 | } 72 | finally { 73 | 74 | 75 | } 76 | 77 | return $content | Where-Object { $_.pccName -like $name } 78 | } 79 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 80 | } 81 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aluserDetail.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALUserDetail { 2 | <# 3 | .SYNOPSIS 4 | Gets detailed information on user from directory junction 5 | .DESCRIPTION 6 | Gets detailed information on user from directory junction 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Unidesk ID of user 11 | .PARAMETER junctionid 12 | Directory junction ID 13 | .PARAMETER lapguid 14 | LDAP guid of user 15 | .PARAMETER dn 16 | LDAP DN of user 17 | .EXAMPLE 18 | Get-ALUserDetail -websession $websession -junctionid $dir.id -ldapguid $userid.DirectoryId.LdapGuid -dn $userid.DirectoryId.LdapDN -id $userid.DirectoryId.UnideskId 19 | #> 20 | [cmdletbinding()] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)][string]$id, 24 | [Parameter(Mandatory = $true)][string]$junctionid, 25 | [Parameter(Mandatory = $true)][string]$ldapguid, 26 | [Parameter(Mandatory = $true)][string]$dn 27 | ) 28 | Begin { 29 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 30 | Test-ALWebsession -WebSession $websession 31 | } 32 | Process { 33 | [xml]$xml = @" 34 | 35 | 36 | 37 | 38 | 39 | $id 40 | $junctionid 41 | $ldapguid 42 | $dn 43 | 44 | 45 | 46 | 47 | 48 | 49 | "@ 50 | Write-Verbose $xml 51 | $headers = @{ 52 | SOAPAction = "http://www.unidesk.com/QueryDirectoryItemDetails"; 53 | "Content-Type" = "text/xml; charset=utf-8"; 54 | UNIDESK_TOKEN = $websession.token; 55 | } 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 58 | [xml]$obj = $return.Content 59 | 60 | 61 | if ($obj.Envelope.Body.QueryDirectoryItemDetailsResponse.QueryDirectoryItemDetailsResult.Error) { 62 | throw $obj.Envelope.Body.QueryDirectoryItemDetailsResponse.QueryDirectoryItemDetailsResult.Error.message 63 | } 64 | else { 65 | return $obj.Envelope.Body.QueryDirectoryItemDetailsResponse.QueryDirectoryItemDetailsResult.Details 66 | } 67 | 68 | } 69 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 70 | } 71 | -------------------------------------------------------------------------------- /docs/use/use_platlayers.md: -------------------------------------------------------------------------------- 1 | # Platform Layers 2 | 3 | ## New Platform Layer 4 | 5 | ```powershell 6 | $fileshare = Get-ALRemoteshare -websession $websession 7 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 8 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 2016 Standard"} 9 | $osrevs = get-aloslayerdetail -websession $websession -id $oss.id 10 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 11 | New-ALPlatformLayer -websession $websession -osrevid $osrevid.Id -name "Citrix XA VDA 7.18" -connectorid $connector.id -shareid $fileshare.id -diskformat $connector.ValidDiskFormats.DiskFormat -type Create 12 | ``` 13 | 14 | ## New Platform Layer Version 15 | 16 | ```powershell 17 | $fileshare = Get-ALRemoteshare -websession $websession 18 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 19 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 10 x64"} 20 | $osrevs = get-aloslayerdetail -websession $websession -id $oss.id 21 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 22 | $plats = Get-ALPlatformlayer -websession $websession|where{$_.name -eq "Windows 10 VDA"} 23 | $platrevs = get-alplatformlayerDetail -websession $websession -id $plats.id 24 | $platformrevid = $platrevs.Revisions.PlatformLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 25 | 26 | $params = @{ 27 | websession = $websession; 28 | osrevid = $osrevid.Id; 29 | connectorid = $connector.Id; 30 | shareid = $fileshare.id; 31 | layerid = $plats.Id; 32 | layerrevid = $platformrevid.id; 33 | version = "5.0"; 34 | Diskname = $plats.Name; 35 | Verbose = $true; 36 | Description = "Citrix VDA 7.18 with windows 10"; 37 | diskformat = $connector.ValidDiskFormats.DiskFormat; 38 | } 39 | 40 | New-ALPlatformLayerRev @params 41 | ``` 42 | ## Remove Platform Layer Revision 43 | 44 | ```powershell 45 | $fileshare = Get-ALRemoteshare -websession $websession 46 | $platformid = Get-ALPlatformlayer -websession $websession | where{$_.name -eq "Windows 10 VDA"} 47 | $platformrevid = Get-ALPlatformlayerDetail -websession $websession -id $platformid.Id 48 | $platformrevid = $platformrevid.Revisions.PlatformLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object DisplayedVersion -Descending | select -First 1 49 | remove-alplatformlayerrev -websession $websession -platformid $platformid.Id -platformrevid $platformrevid.id -fileshareid $fileshare.id 50 | ``` -------------------------------------------------------------------------------- /AppVeyor/deploy.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param( 3 | 4 | ) 5 | # Line break for readability in AppVeyor console 6 | Write-Host -Object '' 7 | Import-Module posh-git -Force 8 | 9 | if ($env:APPVEYOR_REPO_BRANCH -ne 'master') 10 | { 11 | Write-Warning -Message "Skipping version increment and publish for branch $env:APPVEYOR_REPO_BRANCH" 12 | } 13 | elseif ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0) 14 | { 15 | Write-Warning -Message "Skipping version increment and publish for pull request #$env:APPVEYOR_PULL_REQUEST_NUMBER" 16 | } 17 | else 18 | { 19 | Try { 20 | $updates = Get-ChildItem $env:APPVEYOR_BUILD_FOLDER -Filter "*.psd1" -Recurse 21 | 22 | $pubme = $false 23 | if($updates.count -gt 0) 24 | { 25 | Write-Verbose $updates 26 | foreach ($update in $updates) 27 | { 28 | $localver = Test-ModuleManifest $update.fullname 29 | $psgallerver = Find-Module $localver.name -Repository PSgallery 30 | if ($psgallerver.version -le $localver.version) 31 | { 32 | Write-Verbose "Updating version and publishing to PSgallery" 33 | $fileVersion = $localver.Version 34 | $newVersion = "{0}.{1}.{2}" -f $fileVersion.Major, $fileVersion.Minor, ($fileVersion.Build + 1) 35 | $funcs = Get-ChildItem -path $env:APPVEYOR_BUILD_FOLDER\ctxal-sdk\Public|select-object basename|sort-object basename 36 | Update-ModuleManifest -Path $update.fullname -ModuleVersion $newVersion -FunctionsToExport $funcs.basename 37 | Publish-Module -Path $update.Directoryname -NuGetApiKey $env:PSGKey 38 | $pubme = $true 39 | } 40 | else 41 | { 42 | Write-Warning "$($localver.name) not found on PSgallery or PSgallery version higher" 43 | } 44 | } 45 | } 46 | else { 47 | Write-Warning "Nothing to update" 48 | } 49 | } 50 | catch { 51 | Write-Warning "Version update failed" 52 | throw $_ 53 | } 54 | 55 | Try 56 | { 57 | if($pubme) 58 | { 59 | git checkout master 60 | git add --all 61 | git commit -m "PSGallery Version Update to $newVersion" 62 | git push origin master 63 | Write-Verbose "Repo has been pushed to github" 64 | } 65 | else { 66 | Write-Verbose "Nothing to push" 67 | } 68 | } 69 | Catch 70 | { 71 | Write-Warning "Github push failed" 72 | throw $_ 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /docs/use/use_applayers.md: -------------------------------------------------------------------------------- 1 | # Application Layers 2 | 3 | ## New Application Layer 4 | 5 | ```powershell 6 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 7 | $fileshare = Get-ALRemoteshare -websession $websession 8 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 10 x64"} 9 | $osrevs = get-aloslayerDetail -websession $websession -id $oss.id 10 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 11 | new-alapplayer -websession $websession -version "1.0" -name "Accounting APP" -description "Accounting application" -connectorid $connector.id -osrevid $osrevid.Id -diskformat $connector.ValidDiskFormats.DiskFormat -OsLayerSwitching BoundToOsLayer -fileshareid $fileshare.id 12 | ``` 13 | 14 | ## New Application Layer Version 15 | 16 | ```powershell 17 | $fileshare = Get-ALRemoteshare -websession $websession 18 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 19 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "7-Zip"} 20 | $oss = Get-ALOsLayer -websession $websession 21 | $osrevs = get-aloslayerdetail -websession $websession -id $app.AssociatedOsLayerId 22 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 23 | $apprevs = get-alapplayerDetail -websession $websession -id $app.Id 24 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 25 | new-alapplayerrev -websession $websession -version "9.0" -name $app.Name -connectorid $connector.id -appid $app.Id -apprevid $apprevid.id -osrevid $osrevid.Id -diskformat $connector.ValidDiskFormats.DiskFormat -fileshareid $fileshare.id 26 | ``` 27 | 28 | ## Set Application Layer 29 | 30 | ```powershell 31 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "7-Zip"} 32 | Set-alapplayer -websession $websession -name "7-Zip" -description "7-zip" -id $app.Id -scriptpath "C:\NeededScript.ps1" -OsLayerSwitching BoundToOsLayer 33 | ``` 34 | ## Remove Application Layer Revision 35 | 36 | ```powershell 37 | $fileshare = Get-ALRemoteshare -websession $websession 38 | $appid = Get-ALapplayer -websession $websession | where{$_.name -eq "7-Zip"} 39 | $apprevid = get-alapplayerDetail -websession $websession -id $appid.Id 40 | $apprevid = $apprevid.Revisions.AppLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object DisplayedVersion -Descending | select -First 1 41 | remove-alapplayerrev -websession $websession -appid $appid.Id -apprevid $apprevid.id -fileshareid $fileshare.id 42 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alappassignment.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALAppassignment { 2 | <# 3 | .SYNOPSIS 4 | Removes a layer(application) assignment to image(template) 5 | .DESCRIPTION 6 | Removes a layer(application) assignment to image(template) 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER apprevid 10 | Application layer version to be removed 11 | .PARAMETER imageid 12 | Image or template where application should be removed 13 | .EXAMPLE 14 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Accounting} 15 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 16 | $apprevs = get-alapplayer -websession $websession -id $app.Id 17 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object revision -Descending|select -First 1 18 | remove-alappassignment -websession $websession -applayerid $apprevid.LayerId -imageid $image.id 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)][string]$applayerid, 24 | [Parameter(Mandatory = $true)][string]$imageid 25 | ) 26 | Begin { 27 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 28 | Test-ALWebsession -WebSession $websession 29 | } 30 | Process { 31 | [xml]$xml = @" 32 | 33 | 34 | 35 | 36 | 37 | 38 | $imageid 39 | 40 | $applayerid 41 | 42 | 0 43 | 44 | 45 | 46 | 47 | 48 | "@ 49 | Write-Verbose $xml 50 | $headers = @{ 51 | SOAPAction = "http://www.unidesk.com/RemoveAppLayerAssignment"; 52 | "Content-Type" = "text/xml; charset=utf-8"; 53 | UNIDESK_TOKEN = $websession.token; 54 | } 55 | 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | 58 | if ($PSCmdlet.ShouldProcess("Removing $applayerid from $imageid")) { 59 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 60 | [xml]$obj = $return.Content 61 | } 62 | } 63 | 64 | 65 | 66 | end { 67 | if ($PSCmdlet.ShouldProcess("Return object")) { 68 | return $obj 69 | } 70 | Write-Verbose "END: $($MyInvocation.MyCommand)" 71 | } 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /docs/use/use_oslayers.md: -------------------------------------------------------------------------------- 1 | # Operating System Layers 2 | 3 | ## Import Operating System 4 | 5 | ### vCenter 6 | 7 | ```powershell 8 | $fileshare = Get-ALRemoteshare -websession $websession 9 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 10 | $shares = get-alremoteshare -websession $websession 11 | #vCenter Command 12 | $vm = Get-VM "Windows2016VM" 13 | $vmid = $vm.Id -replace "VirtualMachine-","" 14 | $response = import-aloslayer -websession $websession -vmname $vm.name -connectorid $connector.id -shareid $fileshare.id -name "Windows 2016" -version "1.0" -vmid $vmid -hypervisor esxi 15 | ``` 16 | 17 | ### Citrix Hypervisor (XenServer) 18 | 19 | Thanks Dan Feller! 20 | 21 | ```powershell 22 | $fileshare = Get-ALRemoteshare -websession $websession 23 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYXenServer"} 24 | $shares = get-alremoteshare -websession $websession 25 | #Xen Command 26 | $XenVM = get-xenvm -name $VMName 27 | $response = import-aloslayer -websession $websession -vmname $vmname -connectorid $connector.id -shareid $fileshare.id -name "Windows 2016" -version "1.0" -vmid $XenVM.uuid -hypervisor xenserver 28 | ``` 29 | 30 | ## New Operating System Layer Version 31 | 32 | ```powershell 33 | $fileshare = Get-ALRemoteshare -websession $websession 34 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 35 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 2016 Standard"} 36 | $osrevs = get-aloslayerDetail -websession $websession -id $oss.id 37 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 38 | $myosrev = new-aloslayerrev -websession $websession -version "2.0" -connectorid $connector.Id -osid $oss.id -osrevid $osrevid.id -diskformat $connector.ValidDiskFormats.DiskFormat -shareid $fileshare.id 39 | 40 | #Keep checking for change in task 41 | do{ 42 | $status = get-alstatus -websession $websession -id $myosrev.WorkTicketId 43 | Start-Sleep -Seconds 5 44 | } Until ($status.state -eq "ActionRequired") 45 | #use function to extract VM NAME from status message 46 | get-alvmname -message $status.WorkItems.WorkItemResult.Status 47 | ``` 48 | 49 | ## Remove Operating System Layer Revision 50 | 51 | ```powershell 52 | $fileshare = Get-ALRemoteshare -websession $websession 53 | $osid = Get-ALOSlayer -websession $websession | where{$_.name -eq "Windows 10 x64"} 54 | $osrevid = Get-ALOSlayerDetail -websession $websession -id $osid.Id 55 | $osrevid = $osrevid.Revisions.OSLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object DisplayedVersion -Descending | select -Last 1 56 | remove-aloslayerrev -websession $websession -osid $osid.Id -osrevid $osrevid.id -fileshareid $fileshare.id 57 | ``` -------------------------------------------------------------------------------- /Examples/GetUserAppAssignments.ps1: -------------------------------------------------------------------------------- 1 | #Returns a list of users with what elastic layers are assigned 2 | 3 | $aplip = "192.168.1.100" 4 | $pass = "mysupersecretpassword" 5 | $username = "administrator" 6 | $SecurePassword = ConvertTo-SecureString $Pass -AsPlainText -Force 7 | $Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword) 8 | $websession = Connect-alsession -aplip $aplip -Credential $Credential -Verbose 9 | #ELM Directory Name 10 | $DirectoryName = "Lab" 11 | 12 | #Final Array 13 | $final = @() 14 | 15 | #Get Directory 16 | $dir = Get-ALDirectory -websession $websession | Where-Object { $_.name -eq $DirectoryName } 17 | 18 | 19 | #Recursive function to find all users 20 | function Get-LDAPUsers { 21 | 22 | param ( 23 | [Parameter()] 24 | [string]$ldapdn 25 | ) 26 | $FULL = Get-ALUserList -websession $websession -dn $ldapdn -junctionid $dir.ID 27 | 28 | foreach ($item in $full) { 29 | if ($item.type -contains "FolderSummary") { 30 | Get-LDAPUsers -ldapdn $item.FullId.LdapDN 31 | } 32 | elseif ($Item.type -eq "UserSummary") { 33 | $item 34 | } 35 | } 36 | 37 | } 38 | 39 | #Call Function 40 | $users = Get-LDAPUsers -ldapdn $dir.LdapDN 41 | 42 | 43 | #Iterate user list 44 | foreach ($user in $Users) { 45 | #Get User Detail 46 | $userdetail = Get-ALUserDetail -websession $websession -junctionid $dir.id -ldapguid $user.DirectoryId.LdapGuid -dn $user.DirectoryId.LdapDN -id $user.DirectoryId.UnideskId 47 | 48 | #Get Groups User is member of 49 | $groups = Get-ALUserGroupMembership -websession $websession -junctionid $dir.id -id $User.DirectoryId.UnideskId -ldapguid $user.FullId.LdapGuid -ldapdn $user.FullId.LdapDN -sid $userdetail.FullId.sid 50 | 51 | #build group array for search 52 | $groupids = @() 53 | $groups | ForEach-Object { $groupids += $_.DirectoryId.UnideskId } 54 | 55 | #add user to group array only if it has an ID 56 | if ($User.DirectoryId.UnideskId -ne 0) { 57 | $groupids += $User.DirectoryId.UnideskId 58 | } 59 | 60 | if ($groupids) { 61 | #Get Apps that User and Groups are assigned to 62 | $apps = Get-ALUserAssignment -websession $websession -id $groupids 63 | 64 | #Iterate each app found 65 | foreach ($app in $apps) { 66 | #Create PS object 67 | $object = [PSCustomObject] @{ 68 | 'UserName' = $user.LoginName 69 | 'UserDN' = $user.FullId.LdapDN 70 | 'AppLayer' = $app.LayerName; 71 | 'Revision' = $app.CurrentRevision; 72 | 'AssignedVia' = $app.AssignedVia; 73 | 'AssignedViaDisplayName' = $app.AssignedViaDisplayName 74 | } 75 | #Add to return object 76 | $final += $object 77 | } 78 | 79 | } 80 | } 81 | 82 | 83 | #Output object 84 | $final | Format-Table -AutoSize -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alusergroupmembership.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALUserGroupMembership { 2 | <# 3 | .SYNOPSIS 4 | Gets group membership of user 5 | .DESCRIPTION 6 | Gets group membership of user 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | Unidesk ID of user 11 | .PARAMETER junctionid 12 | Directory Junction ID 13 | .PARAMETER ldapguid 14 | User LDAP guid 15 | .PARAMETER ldapdn 16 | User LDAP DN 17 | .PARAMETER sid 18 | User SID 19 | .EXAMPLE 20 | Get-ALUserGroupMembership -websession $websession -junctionid $dir.id -id $User.DirectoryId.UnideskId -ldapguid $user.FullId.LdapGuid -ldapdn $user.FullId.LdapDN -sid $userdetail.FullId.sid 21 | #> 22 | [cmdletbinding()] 23 | Param( 24 | [Parameter(Mandatory = $true)]$websession, 25 | [Parameter(Mandatory = $true)][string]$id, 26 | [Parameter(Mandatory = $true)][string]$junctionid, 27 | [Parameter(Mandatory = $true)][string]$ldapguid, 28 | [Parameter(Mandatory = $true)][string]$ldapdn, 29 | [Parameter(Mandatory = $true)][string]$sid 30 | ) 31 | Begin { 32 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 33 | Test-ALWebsession -WebSession $websession 34 | } 35 | Process { 36 | [xml]$xml = @" 37 | 38 | 39 | 40 | 41 | 42 | $id 43 | $junctionid 44 | $ldapguid 45 | $ldapdn 46 | $sid 47 | 48 | 49 | 50 | 51 | 52 | "@ 53 | Write-Verbose $xml 54 | $headers = @{ 55 | SOAPAction = "http://www.unidesk.com/QueryDirectoryItemGroupMembership"; 56 | "Content-Type" = "text/xml; charset=utf-8"; 57 | UNIDESK_TOKEN = $websession.token; 58 | } 59 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 60 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 61 | [xml]$obj = $return.Content 62 | 63 | if ($obj.Envelope.Body.QueryDirectoryItemGroupMembershipResponse.QueryDirectoryItemGroupMembershipResult.Error) { 64 | throw $obj.Envelope.Body.QueryDirectoryItemGroupMembershipResponse.QueryDirectoryItemGroupMembershipResult.Error.message 65 | } 66 | else { 67 | return $obj.Envelope.Body.QueryDirectoryItemGroupMembershipResponse.QueryDirectoryItemGroupMembershipResult.Groups.GroupSummary 68 | } 69 | 70 | } 71 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 72 | } 73 | -------------------------------------------------------------------------------- /docs/use/use_exportimportlayers.md: -------------------------------------------------------------------------------- 1 | # Export and Import Layers 2 | 3 | Gets "Exportable" Layers 4 | 5 | ```powershell 6 | $mypath = "\\mynas\layershare\" 7 | Get-ALExportableRev -websession $websession -sharepath $mypath 8 | ``` 9 | 10 | Gets "Exportable" layers including ones that are already present 11 | 12 | ```powershell 13 | $mypath = "\\mynas\layershare\" 14 | Get-ALExportableRev -websession $websession -sharepath $mypath -showall 15 | ``` 16 | 17 | Gets "Importable" Layers 18 | 19 | ```powershell 20 | $mypath = "\\mynas\layershare\" 21 | Get-ALimportableRev -websession $websession -sharepath $mypath 22 | ``` 23 | 24 | Gets "Importable" layers including ones that are already present 25 | 26 | ```powershell 27 | $mypath = "\\mynas\layershare\" 28 | Get-ALimportableRev -websession $websession -sharepath $mypath -showall 29 | ``` 30 | 31 | ## Export Layers 32 | 33 | Exports all "exportable" layers to fileshare 34 | 35 | ```powershell 36 | $mypath = "\\mynas\layershare\" 37 | Get-ALExportableRev -websession $websession -sharepath $mypath|Export-ALlayerrev -websession $websession -sharepath $mypath 38 | ``` 39 | 40 | Exports all "exportable" layers to fileshare with authenication. (Press CTRL key to select more than one layer) 41 | 42 | ```powershell 43 | $mypath = "\\mynas\layershare\" 44 | $myusername = "mydomain@domain.com" 45 | $sharepw = "mysupersecret" 46 | Get-ALExportableRev -websession $websession -sharepath $mypath -username $myusername -sharepw $sharepw|Export-ALlayerrev -websession $websession -sharepath $mypath -username $myusername -sharepw $sharepw 47 | ``` 48 | 49 | Allows user to select which layers to export. (Press CTRL key to select more than one layer) 50 | 51 | ```powershell 52 | $mypath = "\\mynas\layershare\" 53 | Get-ALExportableRev -websession $websession -sharepath $mypath|Out-gridview -PassThru|Export-ALlayerrev -websession $websession -sharepath $mypath 54 | ``` 55 | 56 | ## Import Layers 57 | 58 | Imports all "importable" layers to fileshare 59 | 60 | ```powershell 61 | $mypath = "\\mynas\layershare\" 62 | Get-ALImportableRev -websession $websession -sharepath $mypath|Import-ALlayerrev -websession $websession -sharepath $mypath 63 | ``` 64 | 65 | Imports all "importable" layers to fileshare with authenication. (Press CTRL key to select more than one layer) 66 | 67 | ```powershell 68 | $mypath = "\\mynas\layershare\" 69 | $myusername = "mydomain@domain.com" 70 | $sharepw = "mysupersecret" 71 | Get-ALImportableRev -websession $websession -sharepath $mypath -username $myusername -sharepw $sharepw|Import-ALlayerrev -websession $websession -sharepath $mypath -username $myusername -sharepw $sharepw 72 | ``` 73 | 74 | Allows user to select which layers to import. (Press CTRL key to select more than one layer) 75 | 76 | ```powershell 77 | $mypath = "\\mynas\layershare\" 78 | Get-ALImportableRev -websession $websession -sharepath $mypath|Out-gridview -PassThru|Import-ALlayerrev -websession $websession -sharepath $mypath 79 | ``` -------------------------------------------------------------------------------- /Tests/Main.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe "General project validation" { 2 | 3 | $scripts = Get-ChildItem ".\ctxal-sdk\" -Recurse -Include *.ps1,*.psm1 4 | 5 | # TestCases are splatted to the script so we need hashtables 6 | $testCase = $scripts | Foreach-Object{@{file=$_}} 7 | It "Script should be valid powershell" -TestCases $testCase { 8 | param($file) 9 | 10 | $file.fullname | Should -Exist 11 | 12 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 13 | $errors = $null 14 | $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) 15 | $errors.Count | Should -Be 0 16 | } 17 | 18 | $testCase = $scripts | Foreach-Object{@{file=$_}} 19 | It "Script should be UTF-8" -TestCases $testCase { 20 | param($file) 21 | Test-Encoding -Path $file.fullname|should -Be 'TRUE' 22 | } 23 | 24 | $scriptAnalyzerRules = Get-ScriptAnalyzerRule 25 | It " should pass ScriptAnalyzer" -TestCases $testCase { 26 | param($file) 27 | $analysis = Invoke-ScriptAnalyzer -Path $file.fullname -Severity @('Warning','Error') -ExcludeRule @("PSAvoidUsingUserNameAndPassWordParams","PSAvoidUsingPlainTextForPassword","PSAvoidUsingConvertToSecureStringWithPlainText") 28 | 29 | forEach ($rule in $scriptAnalyzerRules) { 30 | if ($analysis.RuleName -contains $rule) { 31 | $analysis | 32 | Where-Object RuleName -EQ $rule -outvariable failures | 33 | Out-Default 34 | $failures.Count | Should -Be 0 35 | } 36 | 37 | } 38 | } 39 | 40 | } 41 | 42 | Describe "Function validation" { 43 | 44 | $scripts = Get-ChildItem ".\ctxal-sdk\" -Recurse -Include *.ps1 45 | $testCase = $scripts | Foreach-Object{@{file=$_}} 46 | It "Script should only contain one function" -TestCases $testCase { 47 | param($file) 48 | $file.fullname | Should -Exist 49 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 50 | $describes = [Management.Automation.Language.Parser]::ParseInput($contents, [ref]$null, [ref]$null) 51 | $test = $describes.FindAll({$args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]}, $true) 52 | $test.Count | Should -Be 1 53 | } 54 | 55 | It " should match function name and contain -AL" -TestCases $testCase { 56 | param($file) 57 | $file.fullname | Should -Exist 58 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 59 | $describes = [Management.Automation.Language.Parser]::ParseInput($contents, [ref]$null, [ref]$null) 60 | $test = $describes.FindAll({$args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]}, $true) 61 | $test[0].name | Should -Be $file.basename 62 | $test[0].name | Should -BeLike "*-AL*" 63 | } 64 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-aloslayerrev.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALOSLayerRev { 2 | <# 3 | .SYNOPSIS 4 | Removes a OS layer version 5 | .DESCRIPTION 6 | Removes a OS layer version 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER osid 10 | Base OS layer version id to use 11 | .PARAMETER osrevid 12 | OS revision version id to use 13 | .EXAMPLE 14 | $fileshare = Get-ALRemoteshare -websession $websession 15 | $osid = Get-ALOSlayer -websession $websession | where{$_.name -eq "Windows 10 x64"} 16 | $osrevid = Get-ALOSlayerDetail -websession $websession -id $osid.Id 17 | $osrevid = $osrevid.Revisions.OSLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object revision -Descending | select -Last 1 18 | remove-aloslayerrev -websession $websession -osid $osid.Id -osrevid $osrevid.id -fileshareid $fileshare.id 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)]$osid, 24 | [Parameter(Mandatory = $true)]$osrevid, 25 | [Parameter(Mandatory = $true)]$fileshareid 26 | ) 27 | Begin { 28 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 29 | Test-ALWebsession -WebSession $websession 30 | } 31 | Process { 32 | [xml]$xml = @" 33 | 34 | 35 | 36 | 37 | $osid 38 | 39 | $osrevid 40 | 41 | 42 | 0 43 | 44 | $fileshareid 45 | 46 | 47 | 48 | 49 | "@ 50 | Write-Verbose $xml 51 | $headers = @{ 52 | SOAPAction = "http://www.unidesk.com/DeleteOsLayerRevisions"; 53 | "Content-Type" = "text/xml; charset=utf-8"; 54 | UNIDESK_TOKEN = $websession.token; 55 | } 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | if ($PSCmdlet.ShouldProcess("Removing $osrevid from $osid")) { 58 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 59 | [xml]$obj = $return.Content 60 | 61 | if ($obj.Envelope.Body.DeleteOsLayerRevisionsResponse.DeleteOsLayerRevisionsResult.Error) { 62 | throw $obj.Envelope.Body.DeleteOsLayerRevisionsResponse.DeleteOsLayerRevisionsResult.Error.message 63 | 64 | } 65 | else { 66 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.DeleteOsLayerRevisionsResponse.DeleteOsLayerRevisionsResult.WorkTicketId)" 67 | return $obj.Envelope.Body.DeleteOsLayerRevisionsResponse.DeleteOsLayerRevisionsResult 68 | } 69 | } 70 | 71 | } 72 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 73 | } 74 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Set-ALAdminUser.ps1: -------------------------------------------------------------------------------- 1 | Function Set-ALAdminUser { 2 | <# 3 | .SYNOPSIS 4 | Sets Administrator User Password 5 | .DESCRIPTION 6 | Sets Administrator User Password 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER Password 10 | New Password for the User 11 | .EXAMPLE 12 | Set-ALAdminUser -websession $websession -Password $PlainPassword -Verbose 13 | #> 14 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 15 | Param( 16 | [Parameter(Mandatory = $true)]$websession, 17 | [Parameter(Mandatory = $false)][string]$Password 18 | ) 19 | 20 | Begin { 21 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 22 | Test-ALWebsession -WebSession $websession 23 | } 24 | 25 | Process { 26 | [xml]$xml = @" 27 | 28 | 29 | 30 | 31 | 32 | 33 | 294912 34 | 0 35 | 36 | 37 | 38 | 39 | 40 | 163847 41 | 42 | Administrator 43 | 44 | Administrator 45 | 46 | 47 | 48 | 49 | <City /> 50 | <State /> 51 | <PostalCode /> 52 | <Country /> 53 | <LoginName>Administrator</LoginName> 54 | <Password>$Password</Password> 55 | </DirectoryItem> 56 | <Reason> 57 | <ReferenceNumber>0</ReferenceNumber> 58 | </Reason> 59 | </command> 60 | </EditDirectoryItem> 61 | </s:Body> 62 | </s:Envelope> 63 | "@ 64 | Write-Verbose $xml 65 | $headers = @{ 66 | SOAPAction = "http://www.unidesk.com/EditDirectoryItem"; 67 | "Content-Type" = "text/xml; charset=utf-8"; 68 | UNIDESK_TOKEN = $websession.token; 69 | } 70 | 71 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 72 | if ($PSCmdlet.ShouldProcess("Setting Administrator Password")) { 73 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 74 | [xml]$obj = $return.Content 75 | 76 | if ($obj.Envelope.Body.EditDirectoryItemResponse.EditDirectoryItemResult.Error) { 77 | throw $obj.Envelope.Body.EditDirectoryItemResponse.EditDirectoryItemResult.Error.message 78 | } 79 | else { 80 | return $obj.Envelope.Body.EditDirectoryItemResponse.EditDirectoryItemResult.id 81 | } 82 | } 83 | } 84 | 85 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 86 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alapplayerrev.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALAppLayerRev { 2 | <# 3 | .SYNOPSIS 4 | Removes a app layer version 5 | .DESCRIPTION 6 | Removes a app layer version 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER appid 10 | Base application layer version id to use 11 | .PARAMETER apprevid 12 | Application revision version id to use 13 | .EXAMPLE 14 | $fileshare = Get-ALRemoteshare -websession $websession 15 | $appid = Get-ALapplayer -websession $websession | where{$_.name -eq "7-Zip"} 16 | $apprevid = get-alapplayerDetail -websession $websession -id $appid.Id 17 | $apprevid = $apprevid.Revisions.AppLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object revision -Descending | select -First 1 18 | remove-alapplayerrev -websession $websession -appid $appid.Id -apprevid $apprevid.id -fileshareid $fileshare.id 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)]$appid, 24 | [Parameter(Mandatory = $true)]$apprevid, 25 | [Parameter(Mandatory = $true)]$fileshareid 26 | ) 27 | Begin { 28 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 29 | Test-ALWebsession -WebSession $websession 30 | } 31 | Process { 32 | [xml]$xml = @" 33 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 34 | <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 35 | <DeleteAppLayerRevisions xmlns="http://www.unidesk.com/"> 36 | <command> 37 | <LayerId>$appid</LayerId> 38 | <RevisionIds> 39 | <long>$apprevid</long> 40 | </RevisionIds> 41 | <Reason> 42 | <ReferenceNumber>0</ReferenceNumber> 43 | </Reason> 44 | <SelectedFileShare>$fileshareid</SelectedFileShare> 45 | </command> 46 | </DeleteAppLayerRevisions> 47 | </s:Body> 48 | </s:Envelope> 49 | "@ 50 | Write-Verbose $xml 51 | $headers = @{ 52 | SOAPAction = "http://www.unidesk.com/DeleteAppLayerRevisions"; 53 | "Content-Type" = "text/xml; charset=utf-8"; 54 | UNIDESK_TOKEN = $websession.token; 55 | } 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | if ($PSCmdlet.ShouldProcess("Removing $apprevid from $appid")) { 58 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 59 | [xml]$obj = $return.Content 60 | 61 | if ($obj.Envelope.Body.DeleteAppLayerRevisionsResponse.DeleteAppLayerRevisionsResult.Error) { 62 | throw $obj.Envelope.Body.DeleteAppLayerRevisionsResponse.DeleteAppLayerRevisionsResult.Error.message 63 | 64 | } 65 | else { 66 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.DeleteAppLayerRevisionsResponse.DeleteAppLayerRevisionsResult.WorkTicketId)" 67 | return $obj.Envelope.Body.DeleteAppLayerRevisionsResponse.DeleteAppLayerRevisionsResult 68 | } 69 | } 70 | 71 | } 72 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 73 | } 74 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-aluserlist.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALUserList { 2 | <# 3 | .SYNOPSIS 4 | Gets list of users and groups for specific LDAP DN 5 | .DESCRIPTION 6 | Gets list of users and groups for specific LDAP DN 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER junctionid 10 | Directory junction ID 11 | .PARAMETER dn 12 | LDAP DN of user location 13 | .EXAMPLE 14 | Get-ALUserList -websession $websession -junctionid $dir.id -dn "CN=Users,DC=mydomain,DC=com" 15 | .EXAMPLE 16 | Get-ALUserList -websession $websession -junctionid $dir.id 17 | #> 18 | [cmdletbinding()] 19 | Param( 20 | [Parameter(Mandatory = $true)]$websession, 21 | [Parameter(Mandatory = $true)][string]$junctionid, 22 | [Parameter(Mandatory = $false)][string]$dn = "" 23 | ) 24 | Begin { 25 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 26 | Test-ALWebsession -WebSession $websession 27 | } 28 | Process { 29 | 30 | if ([string]::IsNullOrWhiteSpace($dn)) { 31 | [xml]$xml = @" 32 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 33 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 34 | <BrowseContainer xmlns="http://www.unidesk.com/"> 35 | <query> 36 | <Id xsi:type="FolderId"> 37 | <UnideskId>$junctionid</UnideskId> 38 | <DirectoryJunctionId>$junctionid</DirectoryJunctionId> 39 | <LdapGuid/> 40 | <LdapDN/> 41 | <Sid/> 42 | </Id> 43 | <FilterType>All</FilterType> 44 | </query> 45 | </BrowseContainer> 46 | </s:Body> 47 | </s:Envelope> 48 | "@ 49 | } 50 | else { 51 | [xml]$xml = @" 52 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 53 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 54 | <BrowseContainer xmlns="http://www.unidesk.com/"> 55 | <query> 56 | <Id xsi:type="FolderId"> 57 | <UnideskId>$junctionid</UnideskId> 58 | <DirectoryJunctionId>$junctionid</DirectoryJunctionId> 59 | <LdapGuid/> 60 | <LdapDN>$dn</LdapDN> 61 | <Sid/> 62 | </Id> 63 | <FilterType>All</FilterType> 64 | </query> 65 | </BrowseContainer> 66 | </s:Body> 67 | </s:Envelope> 68 | "@ 69 | } 70 | Write-Verbose $xml 71 | $headers = @{ 72 | SOAPAction = "http://www.unidesk.com/BrowseContainer"; 73 | "Content-Type" = "text/xml; charset=utf-8"; 74 | UNIDESK_TOKEN = $websession.token; 75 | } 76 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 77 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 78 | [xml]$obj = $return.Content 79 | 80 | if ($obj.Envelope.Body.BrowseContainerResponse.BrowseContainerResult.Error) { 81 | throw $obj.Envelope.Body.BrowseContainerResponse.BrowseContainerResult.Error.message 82 | } 83 | else { 84 | return $obj.Envelope.Body.BrowseContainerResponse.BrowseContainerResult.Items.DirectoryItem 85 | } 86 | 87 | } 88 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 89 | } 90 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/add-alappassignment.ps1: -------------------------------------------------------------------------------- 1 | function Add-ALAppAssignment { 2 | <# 3 | .SYNOPSIS 4 | Adds a layer(application) assignment to image(template) 5 | .DESCRIPTION 6 | Adds a layer(application) assignment to image(template) 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER apprevid 10 | Application layer version to be added 11 | .PARAMETER imageid 12 | Image or template where application should be added 13 | .EXAMPLE 14 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Accounting} 15 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "Libre Office"} 16 | $apprevs = get-alapplayerDetail -websession $websession -id $app.Id 17 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object revision -Descending|select -First 1 18 | add-alappassignment -websession $websession -apprevid $apprevid.id -imageid $image.id 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)][string]$apprevid, 24 | [Parameter(Mandatory = $true)][string]$imageid 25 | ) 26 | Begin { 27 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 28 | Test-ALWebsession -WebSession $websession 29 | } 30 | Process { 31 | [xml]$xml = @" 32 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 33 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 34 | <UpdateAppLayerAssignment xmlns="http://www.unidesk.com/"> 35 | <command> 36 | <AdEntityIds/> 37 | <LayeredImageIds> 38 | <long>$imageid</long> 39 | </LayeredImageIds> 40 | <AppLayerRevId>$apprevid</AppLayerRevId> 41 | <Reason> 42 | <ReferenceNumber>0</ReferenceNumber> 43 | </Reason> 44 | </command> 45 | </UpdateAppLayerAssignment> 46 | </s:Body> 47 | </s:Envelope> 48 | "@ 49 | Write-Verbose $xml 50 | $headers = @{ 51 | SOAPAction = "http://www.unidesk.com/UpdateAppLayerAssignment"; 52 | "Content-Type" = "text/xml; charset=utf-8"; 53 | UNIDESK_TOKEN = $websession.token; 54 | } 55 | if ($PSCmdlet.ShouldProcess("Adding $apprevid to $imageid")) { 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 58 | [xml]$obj = $return.Content 59 | } 60 | } 61 | 62 | 63 | 64 | end { 65 | if ($PSCmdlet.ShouldProcess("Printing output for app add")) { 66 | if ($obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.Error) { 67 | throw $obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.Error.message 68 | 69 | } 70 | else { 71 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.WorkTicketId)" 72 | return $obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.WorkTicketId 73 | } 74 | } 75 | Write-Verbose "END: $($MyInvocation.MyCommand)" 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/get-alldapobject.ps1: -------------------------------------------------------------------------------- 1 | function Get-ALLdapObject { 2 | <# 3 | .SYNOPSIS 4 | Locates LDAP user or group object 5 | .DESCRIPTION 6 | Locates LDAP user or group object 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER object 10 | Group or user to be located 11 | .EXAMPLE 12 | get-alldapobject -websession $websession -object "myusername" 13 | .EXAMPLE 14 | $users = @('MyGroup1','MyGroup2','Domain Users') 15 | $finduser = $users|get-alldapobject -websession $websession 16 | #> 17 | [cmdletbinding()] 18 | Param( 19 | [Parameter(Mandatory = $true)]$websession, 20 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)][string]$object 21 | ) 22 | 23 | begin { 24 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 25 | Test-ALWebsession -WebSession $websession 26 | $finalobj = @() 27 | } 28 | 29 | process { 30 | [xml]$xml = @" 31 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 32 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 33 | <SearchDirectoryItemPendingOp xmlns="http://www.unidesk.com/"> 34 | <query> 35 | <SearchString>$object</SearchString> 36 | <Types>User Group Folder</Types> 37 | <Location>LDAP</Location> 38 | </query> 39 | </SearchDirectoryItemPendingOp> 40 | </s:Body> 41 | </s:Envelope> 42 | "@ 43 | Write-Verbose $xml 44 | $headers = @{ 45 | SOAPAction = "http://www.unidesk.com/SearchDirectoryItemPendingOp"; 46 | "Content-Type" = "text/xml; charset=utf-8"; 47 | UNIDESK_TOKEN = $websession.token; 48 | } 49 | 50 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 51 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 52 | [xml]$obj = $return.Content 53 | 54 | $taskid = $obj.Envelope.Body.SearchDirectoryItemPendingOpResponse.SearchDirectoryItemPendingOpResult.Id 55 | Write-Verbose "Found ID: $taskid" 56 | do { 57 | Write-Verbose "Searching LDAP.." 58 | Start-Sleep -Seconds 1 59 | $pendobj = get-Alpendingop -id $taskid -WebSession $websession 60 | } Until ($pendobj.running -eq "False" ) 61 | 62 | if ($pendobj.OperationResult.Items -ne "") { 63 | $tempobj = [PSCustomObject]@{ 64 | Name = $pendobj.OperationResult.Items.SearchResult["Item"].Name 65 | GUID = $pendobj.OperationResult.Items.SearchResult["Item"].FullId.LdapGuid 66 | DirectoryJunctionId = $pendobj.OperationResult.Items.SearchResult["Item"].FullId.DirectoryJunctionId 67 | ObjectType = $pendobj.OperationResult.Items.SearchResult["Item"].DirectoryId.type 68 | UnideskId = $pendobj.OperationResult.Items.SearchResult["Item"].FullId.UnideskId 69 | DN = $pendobj.OperationResult.Items.SearchResult["Item"].FullId.LdapDN 70 | SID = $pendobj.OperationResult.Items.SearchResult["Item"].FullId.Sid 71 | } 72 | $finalobj += $tempobj 73 | } 74 | else { 75 | Write-Warning "$object NOT FOUND" 76 | } 77 | } 78 | 79 | end { 80 | if ($tempobj) { 81 | return $finalobj 82 | } 83 | Write-Verbose "END: $($MyInvocation.MyCommand)" 84 | } 85 | 86 | 87 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alplatformlayerrev.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALPlatformLayerRev { 2 | <# 3 | .SYNOPSIS 4 | Removes a platform layer version 5 | .DESCRIPTION 6 | Removes a platform layer version 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER platformid 10 | Base platform layer version id to use 11 | .PARAMETER platformrevid 12 | Platform revision version id to use 13 | .EXAMPLE 14 | $fileshare = Get-ALRemoteshare -websession $websession 15 | $platformid = Get-ALPlatformlayer -websession $websession | where{$_.name -eq "Windows 10 VDA"} 16 | $platformrevid = Get-ALPlatformlayerDetail -websession $websession -id $platformid.Id 17 | $platformrevid = $platformrevid.Revisions.PlatformLayerRevisionDetail | where{$_.candelete -eq $true} | Sort-Object revision -Descending | select -First 1 18 | remove-alplatformlayerrev -websession $websession -platformid $platformid.Id -platformrevid $platformrevid.id -fileshareid $fileshare.id 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)]$platformid, 24 | [Parameter(Mandatory = $true)]$platformrevid, 25 | [Parameter(Mandatory = $true)]$fileshareid 26 | ) 27 | Begin { 28 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 29 | Test-ALWebsession -WebSession $websession 30 | } 31 | Process { 32 | [xml]$xml = @" 33 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 34 | <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 35 | <DeletePlatformLayerRevisions xmlns="http://www.unidesk.com/"> 36 | <command> 37 | <LayerId>$platformid</LayerId> 38 | <RevisionIds> 39 | <long>$platformrevid</long> 40 | </RevisionIds> 41 | <Reason> 42 | <ReferenceNumber>0</ReferenceNumber> 43 | </Reason> 44 | <SelectedFileShare>$fileshareid</SelectedFileShare> 45 | </command> 46 | </DeletePlatformLayerRevisions> 47 | </s:Body> 48 | </s:Envelope> 49 | "@ 50 | Write-Verbose $xml 51 | $headers = @{ 52 | SOAPAction = "http://www.unidesk.com/DeletePlatformLayerRevisions"; 53 | "Content-Type" = "text/xml; charset=utf-8"; 54 | UNIDESK_TOKEN = $websession.token; 55 | } 56 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 57 | if ($PSCmdlet.ShouldProcess("Removing $platformrevid from $platformid")) { 58 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 59 | [xml]$obj = $return.Content 60 | 61 | if ($obj.Envelope.Body.DeletePlatformLayerRevisionsResponse.DeletePlatformLayerRevisionsResult.Error) { 62 | throw $obj.Envelope.Body.DeletePlatformLayerRevisionsResponse.DeletePlatformLayerRevisionsResult.Error.message 63 | 64 | } 65 | else { 66 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.DeletePlatformLayerRevisionsResponse.DeletePlatformLayerRevisionsResult.WorkTicketId)" 67 | return $obj.Envelope.Body.DeletePlatformLayerRevisionsResponse.DeletePlatformLayerRevisionsResult 68 | } 69 | } 70 | 71 | } 72 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 73 | } 74 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/remove-alelappassignment.ps1: -------------------------------------------------------------------------------- 1 | function Remove-ALELAppassignment { 2 | <# 3 | .SYNOPSIS 4 | Removes a user account or group to an applications elastic layer assignment 5 | .DESCRIPTION 6 | Removes a user account or group to an applications elastic layer assignment 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER apprevid 10 | Application version layer ID 11 | .PARAMETER user 12 | LDAP located user object 13 | .EXAMPLE 14 | $user = get-alldapobject -websession $websession -object "myusername" 15 | remove-alelappassignment -websession $websession -apprevid $apprevid.Id -user $user 16 | .EXAMPLE 17 | $users = @('MyGroup1','MyGroup2','Domain Users') 18 | $finduser = $users|get-alldapobject -websession $websession 19 | $app = Get-ALapplayerDetail -websession $websession|where{$_.name -eq "Libre Office"} 20 | $apprevs = Get-ALapplayerDetail -websession $websession -id $app.Id 21 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object revision -Descending|select -First 1 22 | $finduser|remove-alelappassignment -websession $websession -apprevid $apprevid.Id 23 | #> 24 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 25 | Param( 26 | [Parameter(Mandatory = $true)]$websession, 27 | [Parameter(Mandatory = $true)][string]$applayerid, 28 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)][string]$user 29 | ) 30 | Begin { 31 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 32 | Test-ALWebsession -WebSession $websession 33 | } 34 | Process { 35 | [xml]$xml = @" 36 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 37 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 38 | <RemoveAppLayerAssignment xmlns="http://www.unidesk.com/"> 39 | <command> 40 | <AdEntityIds> 41 | <DirectoryId xsi:type="$($user.objecttype)"> 42 | <UnideskId>$($user.UnideskId)</UnideskId> 43 | <DirectoryJunctionId>$($user.DirectoryJunctionId)</DirectoryJunctionId> 44 | <LdapGuid>$($user.GUID)</LdapGuid> 45 | <LdapDN>$($user.DN)</LdapDN> 46 | <Sid/> 47 | </DirectoryId> 48 | </AdEntityIds> 49 | <LayeredImageIds/> 50 | <AppLayerId>$applayerid</AppLayerId> 51 | <Reason> 52 | <ReferenceNumber>0</ReferenceNumber> 53 | </Reason> 54 | </command> 55 | </RemoveAppLayerAssignment> 56 | </s:Body> 57 | </s:Envelope> 58 | "@ 59 | Write-Verbose $xml 60 | $headers = @{ 61 | SOAPAction = "http://www.unidesk.com/RemoveAppLayerAssignment"; 62 | "Content-Type" = "text/xml; charset=utf-8"; 63 | UNIDESK_TOKEN = $websession.token; 64 | } 65 | 66 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 67 | if ($PSCmdlet.ShouldProcess("Removing $($user.DN) from $applayerid")) { 68 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 69 | [xml]$obj = $return.Content 70 | } 71 | } 72 | 73 | 74 | 75 | 76 | end { 77 | if ($PSCmdlet.ShouldProcess("Return object")) { 78 | return $obj 79 | } 80 | Write-Verbose "END: $($MyInvocation.MyCommand)" 81 | } 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/invoke-allayerfinalize.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-ALLayerFinalize { 2 | <# 3 | .SYNOPSIS 4 | Runs finalize process on a layer 5 | .DESCRIPTION 6 | Runs finalize process on a layer 7 | .PARAMETER fileshareid 8 | ID of file share location used to store disk 9 | .PARAMETER LayerRevisionId 10 | Revision ID of layer to be finalized 11 | .PARAMETER uncpath 12 | UNC Path of fileshare 13 | .PARAMETER filename 14 | Filename of the disk 15 | .PARAMETER websession 16 | Existing Webrequest session for ELM Appliance 17 | .EXAMPLE 18 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "7-Zip"} 19 | $apprevs = get-alapplayerdetail -websession $websession -id $app.Id 20 | $shares = get-alremoteshare -websession $websession 21 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Finalizable"}|Sort-Object revision -Descending|select -First 1 22 | $disklocation = get-allayerinstalldisk -websession $websession -layerid $apprevid.LayerId 23 | invoke-allayerfinalize -websession $websession -fileshareid $shares.id -LayerRevisionId $apprevid.Id -uncpath $disklocation.diskuncpath -filename $disklocation.diskname 24 | #> 25 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 26 | Param( 27 | [Parameter(Mandatory = $true)]$websession, 28 | [Parameter(Mandatory = $true)][string]$fileshareid, 29 | [Parameter(Mandatory = $true)][string]$LayerRevisionId, 30 | [Parameter(Mandatory = $true)][string]$uncpath, 31 | [Parameter(Mandatory = $true)][string]$filename 32 | ) 33 | Begin { 34 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 35 | Test-ALWebsession -WebSession $websession 36 | } 37 | Process { 38 | [xml]$xml = @" 39 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 40 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 41 | <FinalizeLayerRevision xmlns="http://www.unidesk.com/"> 42 | <command> 43 | <SelectedFileShare>$fileshareid</SelectedFileShare> 44 | <LayerRevisionId>$LayerRevisionId</LayerRevisionId> 45 | <InstallDiskUncPath>$uncpath</InstallDiskUncPath> 46 | <InstallDiskFilename>$filename</InstallDiskFilename> 47 | <ScriptPath/> 48 | <Reason> 49 | <ReferenceNumber>0</ReferenceNumber> 50 | </Reason> 51 | </command> 52 | </FinalizeLayerRevision> 53 | </s:Body> 54 | </s:Envelope> 55 | "@ 56 | Write-Verbose $xml 57 | $headers = @{ 58 | SOAPAction = "http://www.unidesk.com/FinalizeLayerRevision"; 59 | "Content-Type" = "text/xml; charset=utf-8"; 60 | UNIDESK_TOKEN = $websession.token; 61 | } 62 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 63 | if ($PSCmdlet.ShouldProcess("Finalizing $LayerRevisionId")) { 64 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 65 | [xml]$obj = $return.Content 66 | if ($obj.Envelope.Body.FinalizeLayerRevisionResponse.FinalizeLayerRevisionResult.Error) { 67 | throw $obj.Envelope.Body.FinalizeLayerRevisionResponse.FinalizeLayerRevisionResult.Error.message 68 | } 69 | else { 70 | return $obj.Envelope.Body.FinalizeLayerRevisionResponse.FinalizeLayerRevisionResult 71 | } 72 | } 73 | 74 | } 75 | 76 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 77 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/connect-alsession.ps1: -------------------------------------------------------------------------------- 1 | function Connect-ALsession { 2 | <# 3 | .SYNOPSIS 4 | Connects to the Citrix Application Layering appliance and creates a web request session 5 | .DESCRIPTION 6 | Connects to the Citrix Application Layering appliance and creates a web request session 7 | .PARAMETER credential 8 | PowerShell credential object 9 | .EXAMPLE 10 | $websession = Connect-alsession -aplip $aplip -Credential $Credential -Verbose 11 | #> 12 | [cmdletbinding()] 13 | Param( 14 | [parameter(Mandatory = $true)][pscredential]$Credential, 15 | [Parameter(Mandatory = $true)][string]$aplip 16 | ) 17 | Begin { 18 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 19 | } 20 | Process { 21 | #https://stackoverflow.com/questions/41897114/unexpected-error-occurred-running-a-simple-unauthorized-rest-query 22 | $code = @" 23 | public class SSLHandler 24 | { 25 | public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler() 26 | { 27 | return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; }); 28 | } 29 | } 30 | "@ 31 | #compile the class 32 | try { 33 | if ([SSLHandler]) { 34 | Write-Verbose "SSLHandler already loaded" 35 | } 36 | } 37 | catch { 38 | Write-Verbose "SSLHandler loading" 39 | Add-Type -TypeDefinition $code 40 | } 41 | 42 | 43 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 44 | #[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} 45 | [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler() 46 | $username = $Credential.UserName 47 | # Needed for escaping characters &,<,>,", and ' 48 | $pass = [System.Security.SecurityElement]::Escape($Credential.GetNetworkCredential().Password) 49 | 50 | [xml]$xml = @" 51 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 52 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 53 | <Login xmlns="http://www.unidesk.com/"> 54 | <command> 55 | <UserName>$username</UserName> 56 | <Password>$pass</Password> 57 | <Culture>en-US</Culture> 58 | <RememberMe>false</RememberMe> 59 | </command> 60 | </Login> 61 | </s:Body> 62 | </s:Envelope> 63 | "@ 64 | Write-Verbose $xml 65 | $headers = @{"SOAPAction" = "http://www.unidesk.com/Login" } 66 | $url = "https://" + $aplip + "/Unidesk.Web/API.asmx" 67 | $login = Invoke-WebRequest -Uri $url -Method Post -Body $xml -ContentType "text/xml" -SessionVariable websession -Headers $headers 68 | [xml]$mylogin = $login.Content 69 | 70 | if ($mylogin.Envelope.Body.LoginResponse.LoginResult.Error) { 71 | throw $mylogin.Envelope.Body.LoginResponse.LoginResult.Error.message 72 | } 73 | else { 74 | $websession | add-member -NotePropertyName 'token' -NotePropertyValue $mylogin.Envelope.body.LoginResponse.LoginResult.Token 75 | $websession | Add-Member -NotePropertyName 'aplip' -NotePropertyValue $aplip 76 | Write-Verbose "TOKEN: $($mylogin.Envelope.body.LoginResponse.LoginResult.Token)" 77 | Write-Verbose "IP $aplip" 78 | return $websession 79 | } 80 | 81 | 82 | } 83 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 84 | } 85 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Set-ALConnectorCred.ps1: -------------------------------------------------------------------------------- 1 | function Set-ALConnectorCred { 2 | <# 3 | .SYNOPSIS 4 | Sets Connector Credentials 5 | .DESCRIPTION 6 | Sets Connector Username and Pass 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER config 10 | Configuration settings for specific connector (Use get-alconnectordetail) 11 | .PARAMETER connector 12 | Configurations for specific connector (Use get-alconnector) 13 | .PARAMETER UserName 14 | Username to be used for Connector 15 | .PARAMETER password 16 | password to be used for Connector 17 | .EXAMPLE 18 | Set-ALconnectorCred -websession $websession -config $ConnectorConfig -connector $connector -username "domain\first.last" -password "Test123 19 | #> 20 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)][string]$username, 24 | [Parameter(Mandatory = $true)][string]$password, 25 | [Parameter(Mandatory = $true)][PSCustomObject]$config, 26 | [Parameter(Mandatory = $true)][PSCustomObject]$connector 27 | ) 28 | Begin { Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" } 29 | 30 | Process { 31 | 32 | #do the request 33 | $headers = @{ 34 | "Cookie" = ("UMCSessionCoookie=" + $($websession.token)) 35 | "Accept" = "*/*" 36 | "Content-Type" = "application/json" 37 | "Host" = "$($websession.aplip):$($connector.ConfigurationSslPort)" 38 | "Referer" = "https://$($websession.aplip):$($connector.ConfigurationSslPort)/ui/" 39 | } 40 | try { 41 | $urlv = "https://$($websession.aplip):$($connector.ConfigurationSslPort)/api/Configurations/Verify" 42 | $url = "https://$($websession.aplip):$($connector.ConfigurationSslPort)/api/Configurations/$($connector.Id)" 43 | 44 | write-verbose "Old Config:" 45 | $config | Format-List 46 | 47 | $config.pccConfig.userName = $username 48 | $config.pccConfig | Add-Member -MemberType NoteProperty -Name password -Value $password 49 | $configjson = $config | ConvertTo-Json -Depth 100 50 | 51 | write-verbose "New Config:" 52 | $config | Format-List 53 | 54 | write-verbose "Verifying Connector Creds..." 55 | Invoke-RestMethod -Method Post -Uri $urlv -WebSession $websession -Headers $headers -Body $configJSON 56 | write-verbose "Changing Connector Creds..." 57 | if ($PSCmdlet.ShouldProcess("Setting Connector Password")) { 58 | $content = Invoke-RestMethod -Method Put -Uri $url -WebSession $websession -Headers $headers -Body $configJSON 59 | write-verbose "Change Successful" 60 | } 61 | 62 | } 63 | catch { 64 | if ($_.ErrorDetails.Message) { 65 | $temp = $_.ErrorDetails.Message | ConvertFrom-Json 66 | if ($temp.message) { 67 | Write-error $temp.message 68 | } 69 | else { 70 | Write-error $temp.error.message 71 | Write-error $temp.error.sqlmessage 72 | write-error $temp.error.staus 73 | } 74 | throw "Process failed!" 75 | } 76 | else { 77 | Write-error $temp.error.message 78 | Write-error $temp.error.sqlmessage 79 | write-error $temp.error.staus 80 | } 81 | } 82 | finally { 83 | 84 | 85 | } 86 | return $content 87 | } 88 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 89 | } 90 | -------------------------------------------------------------------------------- /ctxal-sdk/Private/Test-ALRemoteFileShare.ps1: -------------------------------------------------------------------------------- 1 | function Test-ALRemoteFileShare { 2 | <# 3 | .SYNOPSIS 4 | Tests remote file share for export import layer processes 5 | .DESCRIPTION 6 | Tests remote file share for export import layer processes 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER sharepath 10 | Share UNC Path type 11 | .PARAMETER sharetype 12 | Share type (Default CIFS) 13 | .PARAMETER username 14 | Share username 15 | .PARAMETER sharepw 16 | Share password 17 | .EXAMPLE 18 | Test-RemoteFileShare -websession $websession -sharepath "\\myserver\path\layers" 19 | #> 20 | [cmdletbinding()] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)][string]$sharepath, 24 | [Parameter(Mandatory = $false)][string]$sharetype = "Cifs", 25 | [Parameter(Mandatory = $false)][string]$username, 26 | [Parameter(Mandatory = $false)][string]$sharepw 27 | ) 28 | Begin { 29 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 30 | Test-ALWebsession -WebSession $websession 31 | } 32 | Process { 33 | 34 | if ($username) { 35 | Write-Verbose "Using Credentials" 36 | [xml]$xml = @" 37 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 38 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 39 | <TestRemoteFileShare xmlns="http://www.unidesk.com/"> 40 | <command> 41 | <ShareId xsi:nil="true"/> 42 | <SharePath>$sharepath</SharePath> 43 | <ShareType>$sharetype</ShareType> 44 | <Username>$username</Username> 45 | <Password>$sharepw</Password> 46 | <Timeout xsi:nil="true"/> 47 | <OnlyCheckCreds>true</OnlyCheckCreds> 48 | </command> 49 | </TestRemoteFileShare> 50 | </s:Body> 51 | </s:Envelope> 52 | "@ 53 | } 54 | else { 55 | Write-Verbose "NO Credentials" 56 | [xml]$xml = @" 57 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 58 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 59 | <TestRemoteFileShare xmlns="http://www.unidesk.com/"> 60 | <command> 61 | <ShareId xsi:nil="true"/> 62 | <SharePath>$sharepath</SharePath> 63 | <ShareType>$sharetype</ShareType> 64 | <Timeout xsi:nil="true"/> 65 | <OnlyCheckCreds>true</OnlyCheckCreds> 66 | </command> 67 | </TestRemoteFileShare> 68 | </s:Body> 69 | </s:Envelope> 70 | "@ 71 | } 72 | 73 | Write-Verbose $xml 74 | $headers = @{ 75 | SOAPAction = "http://www.unidesk.com/TestRemoteFileShare"; 76 | "Content-Type" = "text/xml; charset=utf-8"; 77 | UNIDESK_TOKEN = $websession.token; 78 | } 79 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 80 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 81 | [xml]$obj = $return.Content 82 | 83 | if ($obj.Envelope.Body.TestRemoteFileShareResponse.TestRemoteFileShareResult.Error) { 84 | Write-Verbose "Problems connecting to share" 85 | throw $obj.Envelope.Body.TestRemoteFileShareResponse.TestRemoteFileShareResult.Error.message 86 | return $false 87 | } 88 | else { 89 | Write-Verbose "Share connection OK" 90 | #return $true 91 | } 92 | 93 | } 94 | 95 | end { 96 | Write-Verbose "END: $($MyInvocation.MyCommand)" 97 | } 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /Examples/UpdateTask.ps1: -------------------------------------------------------------------------------- 1 | # Used with OS update Citrix ELM versions 2 | # Ryan Butler 2018-10-17 @ryan_c_butler 3 | # From: https://github.com/ryancbutler/UnideskSDK 4 | 5 | #Modules Needed 6 | Import-Module -name pswindowsupdate 7 | Import-Module -Name Autologon 8 | 9 | #Local admin password 10 | $localadminpw = "MYSECRETPASS" 11 | $localadminuser = "administrator" 12 | 13 | #### Script Starts Here #### 14 | 15 | #wait for Windows update funciton 16 | function Test-WUInstallerStatus { 17 | while ((Get-WUInstallerStatus).IsBusy) { 18 | Write-host -Message "Waiting for Windows update to become free..." -ForegroundColor Yellow 19 | Start-Sleep -Seconds 15 20 | } 21 | } 22 | 23 | #Enable Windows Update Service 24 | write-host "Starting Windows Update Service" 25 | Set-Service wuauserv -StartupType Automatic 26 | Start-Service wuauserv 27 | 28 | #Make sure no other Windows update process is running 29 | write-host "Checking Windows Update Process" 30 | Test-WUInstallerStatus 31 | 32 | #Get Updates 33 | write-host "Getting Available Updates" 34 | $updates = Get-WUList 35 | 36 | #Download and install 37 | if ($updates) { 38 | Write-Host "Installing Updates" 39 | Get-WUInstall -AcceptAll -install -IgnoreReboot 40 | } 41 | 42 | #Wait for Windows Update to start if needed 43 | Start-Sleep -Seconds 5 44 | 45 | #Make sure no other Windows update process is running 46 | Test-WUInstallerStatus 47 | 48 | write-host "Checking for reboot" 49 | if (Get-WURebootStatus -silent) { 50 | #Needs to reboot 51 | #Enabling autologon 52 | Enable-AutoLogon -Username $localadminuser -Password (ConvertTo-SecureString -String $localadminpw -AsPlainText -Force) -LogonCount "1" 53 | Restart-Computer -Force 54 | } 55 | else { 56 | #WU Reboot not needed 57 | 58 | #Flag to use during seal process checks 59 | $good = $true 60 | 61 | #First Section of the "Shutdown for Finalize" 62 | & 'C:\Program Files\Unidesk\Uniservice\Uniservice.exe' -G 63 | #If error with above 64 | if ($? -eq $false) { 65 | write-host "Issues with seal process. Rebooting Again" 66 | #Enable autologon to kick off scheduled task 67 | Enable-AutoLogon -Username $localadminuser -Password (ConvertTo-SecureString -String $localadminpw -AsPlainText -Force) -LogonCount "1" 68 | #Set flag 69 | $good = $false 70 | #Reboot to initialize task 71 | Restart-Computer -Force 72 | } 73 | 74 | #Second Section of the "Shutdown for Finalize" 75 | & 'C:\Program Files\Unidesk\Uniservice\Uniservice.exe' -L 76 | #If error with above 77 | if ($? -eq $false) { 78 | write-host "Issues with seal process. Rebooting Again" 79 | #Enable autologon to kick off scheduled task 80 | Enable-AutoLogon -Username $localadminuser -Password (ConvertTo-SecureString -String $localadminpw -AsPlainText -Force) -LogonCount "1" 81 | #Set flag 82 | $good = $false 83 | #Reboot to initialize task 84 | Restart-Computer -Force 85 | } 86 | 87 | #If checks pass 88 | if ($good) { 89 | #Disable windows update services 90 | write-host "Disabling Windows Update Service" 91 | Set-Service wuauserv -StartupType Disabled 92 | Stop-Service wuauserv 93 | #Remove Scheduled Task 94 | write-host "Removing Scheduled Task" 95 | Unregister-ScheduledTask -TaskName "PSWindowsUpdate" -Confirm:$false 96 | #Remove update script 97 | remove-item "C:\Windows\temp\UpdateTask.ps1" -force 98 | #Shutdown system 99 | & "C:\Windows\System32\Shutdown.exe" /s /t 0 /d p:4:2 /c "Citrix layer finalization" 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Invoke-ALPublish.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-ALPublish { 2 | <# 3 | .SYNOPSIS 4 | Publishes image(template) 5 | .DESCRIPTION 6 | Publishes image(template) 7 | .PARAMETER imageid 8 | Image ID's to be published 9 | .PARAMETER websession 10 | Existing Webrequest session for ELM Appliance 11 | .EXAMPLE 12 | $images = Get-ALimage -websession $websession|where{$_.name -eq "Win 10 Accounting"} 13 | $image = get-alimagedetail -websession $websession -id $images.Id 14 | invoke-alpublish -websession $websession -imageid $images.id 15 | #> 16 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 17 | Param( 18 | [Parameter(Mandatory = $true)]$websession, 19 | [Parameter(Mandatory = $true)][array]$imageid, 20 | [Parameter(Mandatory = $false)][array]$description = "" 21 | ) 22 | Begin { 23 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 24 | Test-ALWebsession -WebSession $websession 25 | } 26 | Process { 27 | if ([string]::IsNullOrWhiteSpace($description)) { 28 | $description = "" 29 | } 30 | 31 | [xml]$xml = @" 32 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 33 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 34 | <ExportImage xmlns="http://www.unidesk.com/"> 35 | <command> 36 | <ImageIds> 37 | <long>$imageid</long> 38 | </ImageIds> 39 | <Reason> 40 | <Description>$description</Description> 41 | <ReferenceNumber>0</ReferenceNumber> 42 | </Reason> 43 | </command> 44 | </ExportImage> 45 | </s:Body> 46 | </s:Envelope> 47 | "@ 48 | Write-Verbose $xml 49 | # If multiple ImageIds are provided loopt trough the $imageid's and merge the xml blocks 50 | if ((![string]::IsNullOrWhiteSpace($imageid)) -and ($imageid.count -gt 1)) { 51 | # Remove original ImageIds node to be able to recreate it as a new element 52 | $ChildNode = "ImageIds" 53 | ($xml.envelope.body.ExportImage.command.ChildNodes | Where-Object { $ChildNode -contains $_.Name }) | ForEach-Object { [void]$_.ParentNode.RemoveChild($_) } 54 | 55 | # Retrieve NamespaceUri from parent 56 | $xdNS = $xml.envelope.body.ExportImage.command.NamespaceURI 57 | 58 | # Define Root Element 59 | $ImageIdsNode = $xml.CreateNode([Xml.XmlNodeType]::Element, $ChildNode, $xdNS); 60 | 61 | # Define Element and values for each provided imageid 62 | for ($i = 0; $i -lt $imageid.Length; $i++) { 63 | 64 | $NewElementName = $xml.CreateNode([Xml.XmlNodeType]::Element, "long", $xdNS); 65 | $NewElementName.InnerText = $imageid[$i] 66 | 67 | # Append the element with their values 68 | $ImageIdsNode.AppendChild($NewElementName) | Out-Null 69 | } 70 | 71 | # Merge with origin 72 | $xml.envelope.body.ExportImage.command.AppendChild($ImageIdsNode) | Out-Null 73 | } 74 | 75 | $headers = @{ 76 | SOAPAction = "http://www.unidesk.com/ExportImage"; 77 | "Content-Type" = "text/xml; charset=utf-8"; 78 | UNIDESK_TOKEN = $websession.token; 79 | } 80 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 81 | if ($PSCmdlet.ShouldProcess("Publishing $imageid")) { 82 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 83 | [xml]$obj = $return.Content 84 | 85 | 86 | if ($obj.Envelope.Body.ExportImageResponse.ExportImageResult.Error) { 87 | throw $obj.Envelope.Body.ExportImageResponse.ExportImageResult.Error.message 88 | 89 | } 90 | else { 91 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.ExportImageResponse.ExportImageResult.WorkTicketId)" 92 | return $obj.Envelope.Body.ExportImageResponse.ExportImageResult.WorkTicketId 93 | } 94 | } 95 | } 96 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 97 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/new-alapplayerclone.ps1: -------------------------------------------------------------------------------- 1 | function New-AlApplayerClone { 2 | <# 3 | .SYNOPSIS 4 | Clones a Layer 5 | .DESCRIPTION 6 | Clones a Layer 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER apprevid 10 | Application revision version id to clone from 11 | .PARAMETER description 12 | Description of the cloned layer 13 | .PARAMETER name 14 | Name of the cloned layer 15 | .PARAMETER targetrevversion 16 | Versionname of the cloned layer revision 17 | .PARAMETER targetrevdescription 18 | Description for the cloned layer revision 19 | .PARAMETER iconid 20 | Icon ID 21 | .EXAMPLE 22 | $layer = Get-ALapplayer -websession $websession | Where-Object {$_.name -like "S2016_APP_JAVA"} 23 | $apprevs = Get-ALapplayerDetail -websession $websession -id $layer.id 24 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail | Sort-Object id | Select-Object -Last 1 25 | $targetrevversion = $apprevid.DisplayedVersion 26 | $targetrevdescription = "Cloned revision $($targetrevversion)" 27 | $name = "$($Layer.name)_Copy" 28 | $description = $($Layer.name) 29 | $Iconid = $(Get-ALicon -websession $websession | Where-Object {$(Get-ALiconassoc -iconid $_.iconid -websession $websession -ea 0) | Where-Object {$_.id -match $layer.id} }).Iconid 30 | #> 31 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 32 | Param( 33 | [Parameter(Mandatory = $true)]$websession, 34 | [Parameter(Mandatory = $true)]$apprevid, 35 | [Parameter(Mandatory = $true)][string]$name, 36 | [Parameter(Mandatory = $false)][string]$description = "", 37 | [Parameter(Mandatory = $false)][string]$iconid = "196608", 38 | [Parameter(Mandatory = $true)][string]$targetrevversion, 39 | [Parameter(Mandatory = $false)][string]$targetrevdescription = "Cloned Revision" 40 | ) 41 | Begin { 42 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 43 | Test-ALWebsession -WebSession $websession 44 | } 45 | Process { 46 | [xml]$xml = @" 47 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 48 | <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 49 | <CloneLayer xmlns="http://www.unidesk.com/"> 50 | <command> 51 | <SourceLayerRevisionId>$apprevid</SourceLayerRevisionId> 52 | <TargetLayerInfo> 53 | <Name>$name</Name> 54 | <Description>$description</Description> 55 | <IconId>$Iconid</IconId> 56 | </TargetLayerInfo> 57 | <TargetRevisionInfo> 58 | <Name>$targetrevversion</Name> 59 | <Description>$targetrevdescription</Description> 60 | <LayerSizeMiB>0</LayerSizeMiB> 61 | </TargetRevisionInfo> 62 | <Reason> 63 | <ReferenceNumber>0</ReferenceNumber> 64 | </Reason> 65 | </command> 66 | </CloneLayer> 67 | </s:Body> 68 | </s:Envelope> 69 | "@ 70 | Write-Verbose $xml 71 | $headers = @{ 72 | SOAPAction = "http://www.unidesk.com/CloneLayer"; 73 | "Content-Type" = "text/xml; charset=utf-8"; 74 | UNIDESK_TOKEN = $websession.token; 75 | } 76 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 77 | if ($PSCmdlet.ShouldProcess("Creating Clone of $apprevid")) 78 | { 79 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 80 | [xml]$obj = $return.Content 81 | 82 | if ($obj.Envelope.Body.CloneLayerResponse.CloneLayerResult.Error) { 83 | throw $obj.Envelope.Body.CloneLayerResponse.CloneLayerResult.Error.message 84 | } 85 | else { 86 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.CloneLayerResponse.CloneLayerResult.WorkTicketId)" 87 | return $obj.Envelope.Body.CloneLayerResponse.CloneLayerResult 88 | } 89 | 90 | } 91 | } 92 | 93 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 94 | } 95 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Export-allayerrev.ps1: -------------------------------------------------------------------------------- 1 | function Export-ALLayerRev { 2 | <# 3 | .SYNOPSIS 4 | Gets revisions that can be used to export 5 | .DESCRIPTION 6 | Gets revisions that can be used to export 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER sharepath 10 | Share UNC Path type 11 | .PARAMETER id 12 | ID(s) of revision layers to export 13 | .PARAMETER username 14 | Share username 15 | .PARAMETER sharepw 16 | Share password 17 | .EXAMPLE 18 | Export-ALlayerrev -websession $websession -sharepath "\\myserver\path\layers" -id @(12042,225252,2412412) 19 | #> 20 | [cmdletbinding()] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)][string]$sharepath, 24 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $True)][string]$id, 25 | [Parameter(Mandatory = $false)][string]$username, 26 | [Parameter(Mandatory = $false)][string]$sharepw 27 | ) 28 | Begin { 29 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 30 | Test-ALWebsession -WebSession $websession 31 | $idsxml = $null 32 | 33 | } 34 | 35 | 36 | Process { 37 | if (!$id) { 38 | Write-Verbose "NOTHING TO DO" 39 | return $false 40 | } 41 | 42 | Write-Verbose "Building XML" 43 | foreach ($revid in $id) { 44 | $idsxml += @" 45 | <anyType xsi:type="xsd:long">$revid</anyType> 46 | "@ 47 | } 48 | } 49 | 50 | end { 51 | if (!$id) { 52 | Write-Verbose "NOTHING TO DO" 53 | return $false 54 | } 55 | 56 | if ($username) { 57 | Write-Verbose "Using Credentials" 58 | test-alremotefileshare -websession $websession -sharepath $sharepath -username $username -sharepw $sharepw 59 | [xml]$xml = @" 60 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 61 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 62 | <ExportLayerRevisions xmlns="http://www.unidesk.com/"> 63 | <command> 64 | <Share> 65 | <ShareId xsi:nil="true"/> 66 | <SharePath>$sharepath</SharePath> 67 | <Username>$username</Username> 68 | <Password>$sharepw</Password> 69 | </Share> 70 | <ExportIds> 71 | $idsxml 72 | </ExportIds> 73 | </command> 74 | </ExportLayerRevisions> 75 | </s:Body> 76 | </s:Envelope> 77 | "@ 78 | } 79 | else { 80 | Write-Verbose "NO Credentials" 81 | test-alremotefileshare -websession $websession -sharepath $sharepath 82 | [xml]$xml = @" 83 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 84 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 85 | <ExportLayerRevisions xmlns="http://www.unidesk.com/"> 86 | <command> 87 | <Share> 88 | <ShareId xsi:nil="true"/> 89 | <SharePath>$sharepath</SharePath> 90 | </Share> 91 | <ExportIds> 92 | $idsxml 93 | </ExportIds> 94 | </command> 95 | </ExportLayerRevisions> 96 | </s:Body> 97 | </s:Envelope> 98 | "@ 99 | } 100 | Write-Verbose $xml 101 | 102 | $headers = @{ 103 | SOAPAction = "http://www.unidesk.com/ExportLayerRevisions"; 104 | "Content-Type" = "text/xml; charset=utf-8"; 105 | UNIDESK_TOKEN = $websession.token; 106 | } 107 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 108 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 109 | [xml]$obj = $return.Content 110 | 111 | if ($obj.Envelope.Body.ExportLayerRevisionsResponse.ExportLayerRevisionsResult.Error) { 112 | throw $obj.Envelope.Body.ExportLayerRevisionsResponse.ExportLayerRevisionsResult.Error.message 113 | } 114 | else { 115 | return $obj.Envelope.Body.ExportLayerRevisionsResponse.ExportLayerRevisionsResult.WorkTicketId 116 | 117 | } 118 | 119 | Write-Verbose "END: $($MyInvocation.MyCommand)" 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/Import-allayerrev.ps1: -------------------------------------------------------------------------------- 1 | function Import-ALLayerRev { 2 | <# 3 | .SYNOPSIS 4 | Imports existing layers from share into ELM 5 | .DESCRIPTION 6 | Imports existing layers from share into ELM 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER sharepath 10 | Share UNC Path type 11 | .PARAMETER id 12 | ID(s) of revision layers to export 13 | .PARAMETER username 14 | Share username 15 | .PARAMETER sharepw 16 | Share password 17 | .EXAMPLE 18 | Import-ALlayerrevs -websession $websession -sharepath "\\myserver\path\layers" -id @(12042,225252,2412412) 19 | #> 20 | [cmdletbinding()] 21 | Param( 22 | [Parameter(Mandatory = $true)]$websession, 23 | [Parameter(Mandatory = $true)][string]$sharepath, 24 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $True)][string]$id, 25 | [Parameter(Mandatory = $false)][string]$username, 26 | [Parameter(Mandatory = $false)][string]$sharepw 27 | ) 28 | Begin { 29 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 30 | Test-ALWebsession -WebSession $websession 31 | $idsxml = $null 32 | } 33 | 34 | 35 | Process { 36 | if (!$id) { 37 | Write-Verbose "NOTHING TO DO" 38 | return $false 39 | } 40 | 41 | Write-Verbose "Building XML" 42 | foreach ($revid in $id) { 43 | $idsxml += @" 44 | <anyType xsi:type="xsd:string">$revid</anyType> 45 | "@ 46 | } 47 | 48 | } 49 | 50 | end { 51 | if (!$id) { 52 | Write-Verbose "NOTHING TO DO" 53 | return $false 54 | } 55 | 56 | if ($username) { 57 | Write-Verbose "Using Credentials" 58 | test-alremotefileshare -websession $websession -sharepath $sharepath -username $username -sharepw $sharepw 59 | [xml]$xml = @" 60 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 61 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 62 | <ImportLayerRevisions xmlns="http://www.unidesk.com/"> 63 | <command> 64 | <Share> 65 | <ShareId xsi:nil="true"/> 66 | <SharePath>$sharepath</SharePath> 67 | <Username>$username</Username> 68 | <Password>$sharepw</Password> 69 | </Share> 70 | <ImportIds> 71 | $idsxml 72 | </ImportIds> 73 | </command> 74 | </ImportLayerRevisions> 75 | </s:Body> 76 | </s:Envelope> 77 | "@ 78 | } 79 | else { 80 | Write-Verbose "NO Credentials" 81 | test-alremotefileshare -websession $websession -sharepath $sharepath 82 | [xml]$xml = @" 83 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 84 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 85 | <ImportLayerRevisions xmlns="http://www.unidesk.com/"> 86 | <command> 87 | <Share> 88 | <ShareId xsi:nil="true"/> 89 | <SharePath>$sharepath</SharePath> 90 | </Share> 91 | <ImportIds> 92 | $idsxml 93 | </ImportIds> 94 | </command> 95 | </ImportLayerRevisions> 96 | </s:Body> 97 | </s:Envelope> 98 | "@ 99 | } 100 | 101 | Write-Verbose $xml 102 | $headers = @{ 103 | SOAPAction = "http://www.unidesk.com/ImportLayerRevisions"; 104 | "Content-Type" = "text/xml; charset=utf-8"; 105 | UNIDESK_TOKEN = $websession.token; 106 | } 107 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 108 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 109 | [xml]$obj = $return.Content 110 | 111 | if ($obj.Envelope.Body.ImportLayerRevisionsResponse.ImportLayerRevisionsResult.Error) { 112 | throw $obj.Envelope.Body.ImportLayerRevisionsResponse.ImportLayerRevisionsResult.Error.message 113 | } 114 | else { 115 | return $obj.Envelope.Body.ImportLayerRevisionsResponse.ImportLayerRevisionsResult.WorkTicketId 116 | 117 | } 118 | 119 | Write-Verbose "END: $($MyInvocation.MyCommand)" 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/test-aldirectory.ps1: -------------------------------------------------------------------------------- 1 | function test-aldirectory { 2 | <# 3 | .SYNOPSIS 4 | Test Directory Junction connectivity 5 | .DESCRIPTION 6 | Test Directory Junction connectivity 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER serveraddress 10 | AD server to connect 11 | .PARAMETER port 12 | AD port (uses 389 and 636 by default) 13 | .PARAMETER usessl 14 | Connect via SSL 15 | .EXAMPLE 16 | test-aldirectory -websession $websession -serveraddress "mydc.domain.com" -Verbose 17 | .EXAMPLE 18 | test-aldirectory -websession $websession -serveraddress "mydc.domain.com" -Verbose -usessl 19 | #> 20 | [cmdletbinding()] 21 | [OutputType([System.boolean])] 22 | Param( 23 | [Parameter(Mandatory = $true)]$websession, 24 | [Parameter(Mandatory = $true)][string]$serveraddress, 25 | [Parameter(Mandatory = $false)][string]$port, 26 | [Parameter(Mandatory = $false)][switch]$usessl 27 | ) 28 | Begin { 29 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 30 | Test-ALWebsession -WebSession $websession 31 | } 32 | Process { 33 | 34 | 35 | if ($usessl) { 36 | 37 | #sets port if not set in parms 38 | if ([string]::IsNullOrWhiteSpace($port)) { 39 | Write-Verbose "Port set to 636" 40 | $port = 636 41 | } 42 | else { 43 | Write-Verbose "Using port $port" 44 | } 45 | 46 | Write-Verbose "Using SSL" 47 | [xml]$xml = @" 48 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 49 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 50 | <TestDirectoryJunction xmlns="http://www.unidesk.com/"> 51 | <command> 52 | <ServerAddress>$serveraddress</ServerAddress> 53 | <ServerPort>$port</ServerPort> 54 | <UseSsl>true</UseSsl> 55 | <AllowableCertificateErrors> 56 | <CertificateError>CnNoMatch</CertificateError> 57 | <CertificateError>Chaining</CertificateError> 58 | </AllowableCertificateErrors> 59 | <RequestedAction>Connect</RequestedAction> 60 | </command> 61 | </TestDirectoryJunction> 62 | </s:Body> 63 | </s:Envelope> 64 | "@ 65 | } 66 | else { 67 | Write-Verbose "NO SSL" 68 | 69 | #sets port if not set in parms 70 | if ([string]::IsNullOrWhiteSpace($port)) { 71 | Write-Verbose "Port set to 389" 72 | $port = 389 73 | } 74 | else { 75 | Write-Verbose "Using port $port" 76 | } 77 | 78 | [xml]$xml = @" 79 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 80 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 81 | <TestDirectoryJunction xmlns="http://www.unidesk.com/"> 82 | <command> 83 | <ServerAddress>$serveraddress</ServerAddress> 84 | <ServerPort>$port</ServerPort> 85 | <UseSsl>false</UseSsl> 86 | <AllowableCertificateErrors/> 87 | <RequestedAction>Connect</RequestedAction> 88 | </command> 89 | </TestDirectoryJunction> 90 | </s:Body> 91 | </s:Envelope> 92 | "@ 93 | } 94 | Write-Verbose $xml 95 | $headers = @{ 96 | SOAPAction = "http://www.unidesk.com/TestDirectoryJunction"; 97 | "Content-Type" = "text/xml; charset=utf-8"; 98 | UNIDESK_TOKEN = $websession.token; 99 | } 100 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 101 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 102 | [xml]$obj = $return.Content 103 | 104 | if ($obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error) { 105 | write-warning $obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error.Message 106 | write-warning $obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error.Details 107 | return $false 108 | } 109 | Write-Verbose "Connected to AD server OK!" 110 | return $true 111 | } 112 | 113 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 114 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/Set-ALOslayer.ps1: -------------------------------------------------------------------------------- 1 | function Set-ALOslayer { 2 | <# 3 | .SYNOPSIS 4 | Edits values of an os layer 5 | .DESCRIPTION 6 | Edits values of an os layer 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | ID of the os layer to edit 11 | .PARAMETER name 12 | Name of the os layer 13 | .PARAMETER description 14 | Description of the layer 15 | .PARAMETER scriptpath 16 | Path of script to be run 17 | .PARAMETER icon 18 | Icon ID 19 | .EXAMPLE 20 | $os = Get-ALoslayer -websession $websession|where{$_.name -eq "Server2016"} 21 | Set-ALoslayer -websession $websession -name "Server2019" -description "7-zip" -id $os.Id -scriptpath "C:\NeededScript.ps1" 22 | #> 23 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 24 | Param( 25 | [Parameter(Mandatory = $true)]$websession, 26 | [Parameter(Mandatory = $true)][string]$id, 27 | [Parameter(Mandatory = $false)][string]$name, 28 | [Parameter(Mandatory = $false)][string]$description, 29 | [Parameter(Mandatory = $false)][string]$scriptpath, 30 | [Parameter(Mandatory = $false)][string]$icon 31 | ) 32 | Begin { 33 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 34 | Test-ALWebsession -WebSession $websession 35 | } 36 | Process { 37 | 38 | $OSlayer = get-alOslayerdetail -websession $websession -id $id 39 | 40 | #Check for existing params 41 | if ([string]::IsNullOrWhiteSpace($name)) { 42 | $name = $OSlayer.LayerSummary.Name 43 | Write-Verbose "Using existing name value $name" 44 | } 45 | 46 | if ([string]::IsNullOrWhiteSpace($description)) { 47 | 48 | $description = $OSlayer.$description 49 | if ([string]::IsNullOrWhiteSpace($OSlayer.$description)) { 50 | $description = "" 51 | } 52 | else { 53 | $description = $OSlayer.description 54 | } 55 | Write-Verbose "Using existing description value $description" 56 | } 57 | 58 | if ([string]::IsNullOrWhiteSpace($scriptpath)) { 59 | Write-Verbose "Using existing host value" 60 | 61 | if ([string]::IsNullOrWhiteSpace($OSlayer.ScriptPath)) { 62 | $scriptpath = "" 63 | } 64 | else { 65 | $scriptpath = $OSlayer.ScriptPath 66 | } 67 | Write-Verbose "Using existing scriptpath value $scriptpath" 68 | } 69 | 70 | if ([string]::IsNullOrWhiteSpace($icon)) { 71 | 72 | $icon = $OSlayer.LayerSummary.ImageId 73 | Write-Verbose "Using existing icon value $icon" 74 | } 75 | 76 | 77 | [xml]$xml = @" 78 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 79 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 80 | <EditLayer xmlns="http://www.unidesk.com/"> 81 | <command> 82 | <Id>$id</Id> 83 | <Name>$name</Name> 84 | <Description>$description</Description> 85 | <IconId>$icon</IconId> 86 | <ScriptPath>$scriptpath</ScriptPath> 87 | <Reason> 88 | <ReferenceNumber>0</ReferenceNumber> 89 | </Reason> 90 | </command> 91 | </EditLayer> 92 | </s:Body> 93 | </s:Envelope> 94 | "@ 95 | Write-Verbose $xml 96 | $xml >> "C:\temp\myxml.xml" 97 | $headers = @{ 98 | SOAPAction = "http://www.unidesk.com/EditLayer"; 99 | "Content-Type" = "text/xml; charset=utf-8"; 100 | UNIDESK_TOKEN = $websession.token; 101 | } 102 | 103 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 104 | if ($PSCmdlet.ShouldProcess("Setting app layer $name")) { 105 | 106 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 107 | [xml]$obj = $return.Content 108 | 109 | if ($obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error) { 110 | throw $obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error.message 111 | 112 | } 113 | else { 114 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.EditLayerResponse.EditLayerResult.WorkTicketId)" 115 | return $true 116 | } 117 | 118 | } 119 | } 120 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 121 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/Set-ALPlatformlayer.ps1: -------------------------------------------------------------------------------- 1 | function Set-ALPlatformlayer { 2 | <# 3 | .SYNOPSIS 4 | Edits values of an platform layer 5 | .DESCRIPTION 6 | Edits values of an platform layer 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | ID of the platformlayer to edit 11 | .PARAMETER name 12 | Name of the platform layer 13 | .PARAMETER description 14 | Description of the layer 15 | .PARAMETER scriptpath 16 | Path of script to be run 17 | .PARAMETER icon 18 | Icon ID 19 | .EXAMPLE 20 | $platform = Get-ALplatformlayer -websession $websession|where{$_.name -eq "XenDesktop"} 21 | Set-ALPlatformlayer -websession $websession -name "XenDesktop" -description "Xendesktop-Layer" -id $platform.Id -scriptpath "C:\NeededScript.ps1" 22 | #> 23 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 24 | Param( 25 | [Parameter(Mandatory = $true)]$websession, 26 | [Parameter(Mandatory = $true)][string]$id, 27 | [Parameter(Mandatory = $false)][string]$name, 28 | [Parameter(Mandatory = $false)][string]$description, 29 | [Parameter(Mandatory = $false)][string]$scriptpath, 30 | [Parameter(Mandatory = $false)][string]$icon 31 | ) 32 | Begin { 33 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 34 | Test-ALWebsession -WebSession $websession 35 | } 36 | Process { 37 | 38 | $platformlayer = get-alPlatformlayerdetail -websession $websession -id $id 39 | 40 | #Check for existing params 41 | if ([string]::IsNullOrWhiteSpace($name)) { 42 | $name = $platformlayer.LayerSummary.Name 43 | Write-Verbose "Using existing name value $name" 44 | } 45 | 46 | if ([string]::IsNullOrWhiteSpace($description)) { 47 | 48 | $description = $platformlayer.$description 49 | if ([string]::IsNullOrWhiteSpace($platformlayer.$description)) { 50 | $description = "" 51 | } 52 | else { 53 | $description = $platformlayer.description 54 | } 55 | Write-Verbose "Using existing description value $description" 56 | } 57 | 58 | if ([string]::IsNullOrWhiteSpace($scriptpath)) { 59 | Write-Verbose "Using existing host value" 60 | 61 | if ([string]::IsNullOrWhiteSpace($platformlayer.ScriptPath)) { 62 | $scriptpath = "" 63 | } 64 | else { 65 | $scriptpath = $platformlayer.ScriptPath 66 | } 67 | Write-Verbose "Using existing scriptpath value $scriptpath" 68 | } 69 | 70 | if ([string]::IsNullOrWhiteSpace($icon)) { 71 | 72 | $icon = $platformlayer.LayerSummary.ImageId 73 | Write-Verbose "Using existing icon value $icon" 74 | } 75 | 76 | 77 | [xml]$xml = @" 78 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 79 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 80 | <EditLayer xmlns="http://www.unidesk.com/"> 81 | <command> 82 | <Id>$id</Id> 83 | <Name>$name</Name> 84 | <Description>$description</Description> 85 | <IconId>$icon</IconId> 86 | <ScriptPath>$scriptpath</ScriptPath> 87 | <Reason> 88 | <ReferenceNumber>0</ReferenceNumber> 89 | </Reason> 90 | </command> 91 | </EditLayer> 92 | </s:Body> 93 | </s:Envelope> 94 | "@ 95 | Write-Verbose $xml 96 | $xml >> "C:\temp\myxml.xml" 97 | $headers = @{ 98 | SOAPAction = "http://www.unidesk.com/EditLayer"; 99 | "Content-Type" = "text/xml; charset=utf-8"; 100 | UNIDESK_TOKEN = $websession.token; 101 | } 102 | 103 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 104 | if ($PSCmdlet.ShouldProcess("Setting app layer $name")) { 105 | 106 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 107 | [xml]$obj = $return.Content 108 | 109 | if ($obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error) { 110 | throw $obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error.message 111 | 112 | } 113 | else { 114 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.EditLayerResponse.EditLayerResult.WorkTicketId)" 115 | return $true 116 | } 117 | 118 | } 119 | } 120 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 121 | } -------------------------------------------------------------------------------- /docs/use/use_connectors.md: -------------------------------------------------------------------------------- 1 | # Connectors 2 | 3 | ## General 4 | 5 | ### Get Connector Detail 6 | 7 | ```powershell 8 | $conn = get-alconnector -websession $websession -type Publish -name "MyconnectorTest7" 9 | get-alconnectordetail -websession $websession -connid $conn.Id -port $conn.ConfigurationSslPort 10 | ``` 11 | 12 | ### Remove Connector 13 | 14 | ```powershell 15 | $conn = get-alconnector -websession $websession -type Publish -name "MyconnectorTest7" 16 | Remove-ALConnector -websession $websession -connid $conn.Id -Confirm:$false 17 | ``` 18 | 19 | ### Set Connector Credentials 20 | 21 | ```powershell 22 | $conn = get-alconnector -websession $websession -type Publish -name "MyconnectorTest7" 23 | $conndetail = get-alconnectordetail -websession $websession -connid $conn.Id -port $conn.ConfigurationSslPort 24 | Set-ALconnectorCred -websession $websession -config $conndetail -connector $conn -username "domain\first.last" -password "Test123 25 | ``` 26 | 27 | ## vCenter 28 | 29 | ### Get vCenter connector(s) information 30 | 31 | ```powershell 32 | Get-alVcenterConnector -websession $websession 33 | ``` 34 | 35 | ### Get vCenter Resource Info 36 | 37 | ```powershell 38 | $vcenter = Get-alVcenterConnector -websession $websession 39 | $dc = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type datacenter -configid $vcenter.pccId 40 | $folder 41 | $hostvar = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type Host -dc $dc.value 42 | $datastore = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type Datastore -dc $dc.value 43 | $network = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type network -dc $dc.value 44 | $template = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type vmTemplate -vmfolder $dc.vmFolder 45 | $folder = get-alvcenterobject -websession $websession -configid $vcenter.pccId -username $vcenter.pccConfig.userName -vcenter $vcenter.pccConfig.vCenterServer -type vmfolder -vmfolder $dc.vmFolder 46 | ``` 47 | 48 | ### Validate and Set vCenter Password 49 | 50 | ```powershell 51 | $vcenter = Get-alVcenterConnector -websession $websession 52 | $vcenter.pccConfig|Add-Member -NotePropertyName "password" -NotePropertyValue "mysecretpassword" 53 | 54 | Set-alVcenterConnector -websession $websession -config $vcenter 55 | ``` 56 | 57 | ### Create vCenter Connector 58 | 59 | ```powershell 60 | $vcenterpassword = "mysupersecretpassword" 61 | $usernamevc = "domain\username" 62 | $vcentername = "myvcenter.domain.local" 63 | $type = get-alconnectortype -websession $websession -name "Citrix MCS for vSphere" 64 | $dc = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type Datacenter -name "Lab" 65 | $hostvar = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type Host -dc $dc.value -name "myhostname" 66 | $datastore = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type Datastore -dc $dc.value -name "nydatastire" 67 | $network = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type network -dc $dc.value -name "VLAN10" 68 | $template = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type vmTemplate -vmfolder $dc.vmFolder -name "CALTEMP" 69 | $folder = get-alvcenterobject -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword -type vmfolder -vmfolder $dc.vmFolder -name "Unidesk" 70 | 71 | 72 | $Params = @{ 73 | Name = "MyconnectorTest" 74 | DC = $dc 75 | DATASTORE = $datastore 76 | HOSTSYSTEM = $hostvar 77 | NETWORK = $network 78 | FOLDER = $folder 79 | CONNID = $type.Id 80 | VMTEMPLATE = $template 81 | CACHESIZE = "250" 82 | } 83 | 84 | new-AlVcenterConnector -websession $websession -username $usernamevc -vcenter $vcentername -vcenterpass $vcenterpassword @params 85 | ``` -------------------------------------------------------------------------------- /docs/use/use_images.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | ## Get Image Composition 4 | 5 | ```powershell 6 | $image = Get-ALImageComp -websession $websession -name "Windows 10 Accounting" 7 | $image.OSLayer 8 | $image.PlatformLayer 9 | $image.AppLayer 10 | ``` 11 | 12 | ## Create New Image 13 | 14 | ```powershell 15 | $fileshare = Get-ALRemoteshare -websession $websession 16 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 17 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 10 x64"} 18 | $osrevs = get-aloslayerDetail -websession $websession -id $oss.id 19 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 20 | $plats = get-alplatformlayer -websession $websession|where{$_.name -eq "Windows 10 VDA"} 21 | $platrevs = get-alplatformlayerdetail -websession $websession -id $plats.id 22 | $platformrevid = $platrevs.Revisions.PlatformLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 23 | #Application IDs 24 | $apps = @("Winscp","7-zip") 25 | $appids = @() 26 | foreach ($app in $apps) 27 | { 28 | $applayerid = Get-ALapplayer -websession $websession|where{$_.name -eq $app} 29 | $apprevs = get-alapplayerDetail -websession $websession -id $applayerid.Id 30 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 31 | $appids += $apprevid.Id 32 | } 33 | new-alimage -websession $websession -name "Windows 10 Accounting" -description "Accounting" -connectorid $connector.id -osrevid $osrevid.Id -appids $appids -platrevid $platformrevid.id -diskformat $connector.ValidDiskFormats.DiskFormat -ElasticLayerMode Session 34 | ``` 35 | 36 | ## Edit Image 37 | 38 | ```powershell 39 | $fileshare = Get-ALRemoteshare -websession $websession 40 | $connector = Get-ALconnector -websession $websession -type Create|where{$_.name -eq "MYvCenter"} 41 | $oss = Get-ALOsLayer -websession $websession|where{$_.name -eq "Windows 10 x64"} 42 | $osrevs = get-aloslayerdetail -websession $websession -id $oss.id 43 | $osrevid = $osrevs.Revisions.OsLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 44 | $plats = Get-ALPlatformlayer -websession $websession|where{$_.name -eq "Windows 10 VDA"} 45 | $platrevs = get-alplatformlayerdetail -websession $websession -id $plats.id 46 | $platformrevid = $platrevs.Revisions.PlatformLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1 47 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Windows 10 Accounting"} 48 | Set-alimage -websession $websession -name $images.Name -description "My new description" -connectorid $connector.id -osrevid $osrevid.Id -platrevid $platformrevid.id -id $image.Id -ElasticLayerMode Session -diskformat $connector.ValidDiskFormats.DiskFormat 49 | ``` 50 | 51 | ### Edit image with latest revision for a specific app or apps 52 | 53 | ```powershell 54 | $apps = @("Winscp","7-zip") 55 | $applayerids = foreach ($app in $apps){Get-ALapplayer -websession $websession|where{$_.name -eq $app}} 56 | $apprevs = foreach ($applayerid in $applayerids){get-alapplayerDetail -websession $websession -id $applayerid.Id} 57 | $apprevid = foreach ($apprev in $apprevs){$apprev.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object DisplayedVersion -Descending|select -First 1} 58 | Set-alimage -websession $websession -name $images.Name -description "My new description" -connectorid $connector.id -osrevid $osrevid.Id -platrevid $platformrevid.id -id $image.Id -ElasticLayerMode Session -diskformat $connector.ValidDiskFormats.DiskFormat -applayerid $apprevid.LayerId -apprevid $apprevid.Id 59 | ``` 60 | 61 | ## Remove Image 62 | 63 | ```powershell 64 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Windows 10 Accounting"} 65 | Remove-ALImage -websession $websession -imageid $image.id 66 | ``` 67 | 68 | ## Publish Image 69 | 70 | ```powershell 71 | $image = Get-ALimage -websession $websession|where{$_.name -eq "Windows 10 Accounting"} 72 | invoke-alpublish -websession $websession -imageid $image.id 73 | ``` 74 | 75 | ## Clone Image 76 | 77 | ```powershell 78 | $image = Get-ALimage -websession $websession | where {$_.name -eq "Windows 10 Accounting"} 79 | New-ALImageClone -websession $websession -imageid $image.Id -Confirm:$false -OutVariable ALImageClone 80 | ``` -------------------------------------------------------------------------------- /ctxal-sdk/Public/add-alelappassignment.ps1: -------------------------------------------------------------------------------- 1 | function Add-ALELAppassignment { 2 | <# 3 | .SYNOPSIS 4 | Adds a user account or group to an applications elastic layer assignment 5 | .DESCRIPTION 6 | Adds a user account or group to an applications elastic layer assignment 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER apprevid 10 | Application version layer ID 11 | .PARAMETER user 12 | LDAP located user object 13 | .EXAMPLE 14 | $user = get-alldapobject -websession $websession -object "myusername" 15 | add-alelappassignment -websession $websession -apprevid $apprevid.Id -unideskid $unideskid -objecttype $objecttype -directoryjunctionid $directoryjunctionid -ldapguid $ldapguid -ldapdn $ldapdn -sid $sid -Confirm:$False 16 | 17 | .EXAMPLE 18 | $users = @('MyGroup1','MyGroup2','Domain Users') 19 | $finduser = $users|get-alldapobject -websession $websession 20 | $app = Get-ALapplayerDetail -websession $websession|where{$_.name -eq "Libre Office"} 21 | $apprevs = Get-ALapplayerDetail -websession $websession -id $app.Id 22 | $apprevid = $apprevs.Revisions.AppLayerRevisionDetail|where{$_.state -eq "Deployable"}|Sort-Object revision -Descending|select -First 1 23 | add-alelappassignment -websession $websession -apprevid $apprevid.Id -unideskid $finduser.unideskid -objecttype $finduser.objecttype -directoryjunctionid $finduser.directoryjunctionid -ldapguid $finduser.guid -ldapdn $finduser.dn -sid $finsuser.sid -Confirm:$False 24 | 25 | #> 26 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 27 | Param( 28 | [Parameter(Mandatory = $true)]$websession, 29 | [Parameter(Mandatory = $true)][string]$apprevid, 30 | [Parameter(Mandatory = $true)][long]$unideskid, 31 | [Parameter(Mandatory = $true)][long]$directoryjunctionid, 32 | [Parameter(Mandatory = $true)][string]$ldapguid, 33 | [Parameter(Mandatory = $true)][string]$ldapdn, 34 | [Parameter(Mandatory = $true)][string]$sid, 35 | [Parameter(Mandatory = $true)][string]$objecttype, 36 | [Parameter(Mandatory = $false)][long]$imageid 37 | ) 38 | 39 | Begin { 40 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 41 | Test-ALWebsession -WebSession $websession 42 | } 43 | Process { 44 | [xml]$xml = @" 45 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 46 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 47 | <UpdateAppLayerAssignment xmlns="http://www.unidesk.com/"> 48 | <command> 49 | <AdEntityIds> 50 | <DirectoryId xsi:type="$objecttype"> 51 | <UnideskId>$unideskid</UnideskId> 52 | <DirectoryJunctionId>$directoryjunctionid</DirectoryJunctionId> 53 | <LdapGuid>$ldapguid</LdapGuid> 54 | <LdapDN>$ldapdn</LdapDN> 55 | <Sid>$sid</Sid> 56 | </DirectoryId> 57 | </AdEntityIds> 58 | <LayeredImageIds> 59 | <long>$imageid</long> 60 | </LayeredImageIds> 61 | <AppLayerRevId>$apprevid</AppLayerRevId> 62 | <Reason> 63 | <ReferenceNumber>0</ReferenceNumber> 64 | </Reason> 65 | </command> 66 | </UpdateAppLayerAssignment> 67 | </s:Body> 68 | </s:Envelope> 69 | "@ 70 | Write-Verbose $xml 71 | $headers = @{ 72 | SOAPAction = "http://www.unidesk.com/UpdateAppLayerAssignment"; 73 | "Content-Type" = "text/xml; charset=utf-8"; 74 | UNIDESK_TOKEN = $websession.token; 75 | } 76 | if ($PSCmdlet.ShouldProcess("Adding $apprevid to $($user.DN)")) { 77 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 78 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 79 | [xml]$obj = $return.Content 80 | } 81 | } 82 | 83 | 84 | 85 | end { 86 | if ($PSCmdlet.ShouldProcess("Output for application add")) { 87 | if ($obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.Error) { 88 | throw $obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.Error.message 89 | 90 | } 91 | else { 92 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.WorkTicketId)" 93 | return $obj.Envelope.Body.UpdateAppLayerAssignmentResponse.UpdateAppLayerAssignmentResult.WorkTicketId 94 | } 95 | } 96 | Write-Verbose "END: $($MyInvocation.MyCommand)" 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /ctxal-sdk/Public/test-aldirectoryauth.ps1: -------------------------------------------------------------------------------- 1 | function test-aldirectoryauth { 2 | <# 3 | .SYNOPSIS 4 | Test Directory Junction authentication 5 | .DESCRIPTION 6 | Test Directory Junction authentication 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER serveraddress 10 | AD server to connect 11 | .PARAMETER port 12 | AD port (uses 389 and 636 by default) 13 | .PARAMETER usessl 14 | Connect via SSL 15 | .PARAMETER username 16 | AD username (eg admin@domain.com) 17 | .PARAMETER adpassword 18 | AD password 19 | .EXAMPLE 20 | test-aldirectoryauth -websession $websession -serveraddress "mydc.domain.com" -Verbose -username "admin@domain.com" -adpassword "MYPASSWORD" 21 | .EXAMPLE 22 | test-aldirectoryauth -websession $websession -serveraddress "mydc.domain.com" -Verbose -usessl -username "admin@domain.com" -adpassword "MYPASSWORD" 23 | #> 24 | [cmdletbinding()] 25 | [OutputType([System.boolean])] 26 | Param( 27 | [Parameter(Mandatory = $true)]$websession, 28 | [Parameter(Mandatory = $true)][string]$serveraddress, 29 | [Parameter(Mandatory = $false)][string]$port, 30 | [Parameter(Mandatory = $false)][switch]$usessl, 31 | [Parameter(Mandatory = $true)][string]$username, 32 | [Parameter(Mandatory = $true)][string]$adpassword 33 | ) 34 | Begin { 35 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 36 | Test-ALWebsession -WebSession $websession 37 | } 38 | Process { 39 | 40 | 41 | if ($usessl) { 42 | 43 | #sets port if not set in parms 44 | if ([string]::IsNullOrWhiteSpace($port)) { 45 | Write-Verbose "Port set to 636" 46 | $port = 636 47 | } 48 | else { 49 | Write-Verbose "Using port $port" 50 | } 51 | 52 | Write-Verbose "Using SSL" 53 | [xml]$xml = @" 54 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 55 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 56 | <TestDirectoryJunction xmlns="http://www.unidesk.com/"> 57 | <command> 58 | <ServerAddress>$serveraddress</ServerAddress> 59 | <ServerPort>$port</ServerPort> 60 | <UserName>$username</UserName> 61 | <Password>$adpassword</Password> 62 | <UseSsl>true</UseSsl> 63 | <AllowableCertificateErrors> 64 | <CertificateError>CnNoMatch</CertificateError> 65 | <CertificateError>Chaining</CertificateError> 66 | </AllowableCertificateErrors> 67 | <RequestedAction>ConnectAndBind</RequestedAction> 68 | </command> 69 | </TestDirectoryJunction> 70 | </s:Body> 71 | </s:Envelope> 72 | "@ 73 | } 74 | else { 75 | Write-Verbose "NO SSL" 76 | 77 | #sets port if not set in parms 78 | if ([string]::IsNullOrWhiteSpace($port)) { 79 | Write-Verbose "Port set to 389" 80 | $port = 389 81 | } 82 | else { 83 | Write-Verbose "Using port $port" 84 | } 85 | 86 | [xml]$xml = @" 87 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 88 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 89 | <TestDirectoryJunction xmlns="http://www.unidesk.com/"> 90 | <command> 91 | <ServerAddress>$serveraddress</ServerAddress> 92 | <ServerPort>$port</ServerPort> 93 | <UserName>$username</UserName> 94 | <Password>$adpassword</Password> 95 | <UseSsl>false</UseSsl> 96 | <AllowableCertificateErrors/> 97 | <RequestedAction>ConnectAndBind</RequestedAction> 98 | </command> 99 | </TestDirectoryJunction> 100 | </s:Body> 101 | </s:Envelope> 102 | "@ 103 | } 104 | Write-Verbose $xml 105 | $headers = @{ 106 | SOAPAction = "http://www.unidesk.com/TestDirectoryJunction"; 107 | "Content-Type" = "text/xml; charset=utf-8"; 108 | UNIDESK_TOKEN = $websession.token; 109 | } 110 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 111 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 112 | [xml]$obj = $return.Content 113 | 114 | if ($obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error) { 115 | write-warning $obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error.Message 116 | write-warning $obj.Envelope.Body.TestDirectoryJunctionResponse.TestDirectoryJunctionResult.Error.Details 117 | return $false 118 | } 119 | Write-Verbose "Connected to AD server OK!" 120 | return $true 121 | } 122 | 123 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 124 | } -------------------------------------------------------------------------------- /ctxal-sdk/Public/set-alapplayer.ps1: -------------------------------------------------------------------------------- 1 | function Set-ALApplayer { 2 | <# 3 | .SYNOPSIS 4 | Edits values of an application layer 5 | .DESCRIPTION 6 | Edits values of an application layer 7 | .PARAMETER websession 8 | Existing Webrequest session for ELM Appliance 9 | .PARAMETER id 10 | ID of the applayer to edit 11 | .PARAMETER name 12 | Name of the application layer 13 | .PARAMETER description 14 | Description of the layer 15 | .PARAMETER scriptpath 16 | Path of script to be run 17 | .PARAMETER icon 18 | Icon ID 19 | .PARAMETER OsLayerSwitching 20 | Allow OS Switching NotBoundToOsLayer=ON BoundToOsLayer=OFF 21 | .EXAMPLE 22 | $app = Get-ALapplayer -websession $websession|where{$_.name -eq "7-Zip"} 23 | Set-alapplayer -websession $websession -name "7-Zip" -description "7-zip" -id $app.Id -scriptpath "C:\NeededScript.ps1" -OsLayerSwitching BoundToOsLayer 24 | #> 25 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 26 | Param( 27 | [Parameter(Mandatory = $true)]$websession, 28 | [Parameter(Mandatory = $true)][string]$id, 29 | [Parameter(Mandatory = $false)][string]$name, 30 | [Parameter(Mandatory = $false)][string]$description, 31 | [Parameter(Mandatory = $false)][string]$scriptpath, 32 | [Parameter(Mandatory = $false)][string]$icon, 33 | [Parameter(Mandatory = $false)][ValidateSet("NotBoundToOsLayer", "BoundToOsLayer")][string]$OsLayerSwitching 34 | ) 35 | Begin { 36 | Write-Verbose "BEGIN: $($MyInvocation.MyCommand)" 37 | Test-ALWebsession -WebSession $websession 38 | } 39 | Process { 40 | 41 | $applayer = get-alapplayerdetail -websession $websession -id $id 42 | 43 | #Check for existing params 44 | if ([string]::IsNullOrWhiteSpace($name)) { 45 | $name = $applayer.LayerSummary.Name 46 | Write-Verbose "Using existing name value $name" 47 | } 48 | 49 | if ([string]::IsNullOrWhiteSpace($description)) { 50 | 51 | $description = $applayer.$description 52 | if ([string]::IsNullOrWhiteSpace($applayer.$description)) { 53 | $description = "" 54 | } 55 | else { 56 | $description = $applayer.description 57 | } 58 | Write-Verbose "Using existing description value $description" 59 | } 60 | 61 | if ([string]::IsNullOrWhiteSpace($scriptpath)) { 62 | Write-Verbose "Using existing host value" 63 | 64 | if ([string]::IsNullOrWhiteSpace($applayer.ScriptPath)) { 65 | $scriptpath = "" 66 | } 67 | else { 68 | $scriptpath = $applayer.ScriptPath 69 | } 70 | Write-Verbose "Using existing scriptpath value $scriptpath" 71 | } 72 | 73 | if ([string]::IsNullOrWhiteSpace($icon)) { 74 | 75 | $icon = $applayer.LayerSummary.ImageId 76 | Write-Verbose "Using existing icon value $icon" 77 | } 78 | 79 | if ([string]::IsNullOrWhiteSpace($OsLayerSwitching)) { 80 | $OsLayerSwitching = $applayer.OsLayerSwitching 81 | Write-Verbose "Using existing OsLayerSwitching value $OsLayerSwitching" 82 | } 83 | 84 | [xml]$xml = @" 85 | <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 86 | <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 87 | <EditLayer xmlns="http://www.unidesk.com/"> 88 | <command> 89 | <Id>$id</Id> 90 | <Name>$name</Name> 91 | <Description>$description</Description> 92 | <IconId>$icon</IconId> 93 | <ScriptPath>$scriptpath</ScriptPath> 94 | <OsLayerSwitching>$OsLayerSwitching</OsLayerSwitching> 95 | <Reason> 96 | <ReferenceNumber>0</ReferenceNumber> 97 | </Reason> 98 | </command> 99 | </EditLayer> 100 | </s:Body> 101 | </s:Envelope> 102 | "@ 103 | Write-Verbose $xml 104 | $xml >> "C:\temp\myxml.xml" 105 | $headers = @{ 106 | SOAPAction = "http://www.unidesk.com/EditLayer"; 107 | "Content-Type" = "text/xml; charset=utf-8"; 108 | UNIDESK_TOKEN = $websession.token; 109 | } 110 | 111 | $url = "https://" + $websession.aplip + "/Unidesk.Web/API.asmx" 112 | if ($PSCmdlet.ShouldProcess("Setting app layer $name")) { 113 | 114 | $return = Invoke-WebRequest -Uri $url -Method Post -Body $xml -Headers $headers -WebSession $websession 115 | [xml]$obj = $return.Content 116 | 117 | if ($obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error) { 118 | throw $obj.Envelope.Body.EditLayerResponse.EditLayerResult.Error.message 119 | 120 | } 121 | else { 122 | Write-Verbose "WORKTICKET: $($obj.Envelope.Body.EditLayerResponse.EditLayerResult.WorkTicketId)" 123 | return $true 124 | } 125 | 126 | } 127 | } 128 | end { Write-Verbose "END: $($MyInvocation.MyCommand)" } 129 | } 130 | --------------------------------------------------------------------------------