Skip to content

Instantly share code, notes, and snippets.

View straff's full-sized avatar
💭
doing ansible stuff

Straff straff

💭
doing ansible stuff
View GitHub Profile
@straff
straff / citrix-vda.yml
Created September 27, 2019 05:02
ansible installer role for citrix vda (virtual desktop agent)
---
# Deploy tasks
- name: "Deploy role {{ role_name }}"
debug:
msg: "################ This role {{ role_name }} is being run in deploy mode and will make changes if it has to! ################"
- set_fact:
citrix_vda_installer_zip: "XenDesktop{{citrix_vda_version}}-subset-for-vda.zip"
citrix_vda_installer_zip_full: "{{temp_folder}}/XenDesktop{{citrix_vda_version}}-subset-for-vda.zip"
# This will return a hash of an individual file or of a folder, optionally recursing folders
# Folder processing logic (sorting on fullname and using fullname as part of agglomerated string) is trying to guard against possibility of things like
# filename changes but order staying the same
#
function Get-SpecialHash( $_file_pattern, $_recurse=$false ) {
if ( -Not (Test-Path $_file_pattern) ) { return Return-HashResult $false 0 "file pattern did not find files $_file_pattern" }
if ( $_recurse ) { $_files = Get-ChildItem $_file_pattern -recurse | Sort-Object -Property Fullname }
else { $_files = Get-ChildItem $_file_pattern | Sort-Object -Property Fullname }
if ( -Not $_files ) { return Return-HashResult $false 0 "file pattern did not find files $_file_pattern" }
if ( $_files.count -eq 1 ) { return Return-HashResult $true 1 "found one file based on pattern $_file_pattern" (Get-FileHash $_files.fullname -Algorithm MD5).hash }
@straff
straff / gist:4006349e8ae18d4838fac154ad2421d7
Created January 12, 2019 03:17
Get-DisplayVersion.ps1
function Get-DisplayVersion( $_displayNamePartial ) {
$_displayNameEscaped = [System.Text.RegularExpressions.Regex]::Escape($_displayNamePartial) # to handle things like 'Microsoft Visual C++ 2013 x86 Additional Runtime' - https://lazywinadmin.com/2014/09/powershell-tip-escape-regex.html
$_results = @()
$_result = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -match "$_displayNameEscaped" }) | Select-Object -Property DisplayName,DisplayVersion
if ( $_result ) { $_results += $_result }
$_result = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -match "$_displayNameEscaped" }) | Select-Object -Property DisplayName,DisplayVersion
if ( $_result ) { $_results += $_result }
if ( $_results.count -eq 0 ) { return (DisplayVersion-Results $false "no instances found for display name $_displayNamePartial" ) }
if ( $_results.count -gt 1 ) { return (DisplayVersion-Results
@straff
straff / gist:ba3630a39ef9e1450f7e8bdd3bfb0b32
Last active January 15, 2019 03:27
win_displayversion
function Get-DisplayVersion( $_displayNamePartial ) {
$_displayNameEscaped = [System.Text.RegularExpressions.Regex]::Escape($_displayNamePartial) # to handle things like 'Microsoft Visual C++ 2013 x86 Additional Runtime' - https://lazywinadmin.com/2014/09/powershell-tip-escape-regex.html
$_results = @()
$_result = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -match "$_displayNameEscaped" }) | Select-Object -Property DisplayName,DisplayVersion
if ( $_result ) { $_results += $_result }
$_result = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -match "$_displayNameEscaped" }) | Select-Object -Property DisplayName,DisplayVersion
if ( $_result ) { $_results += $_result }
if ( $_results.count -eq 0 ) { return (DisplayVersion-Object $false "no instances found for display name $_displayNamePartial" ) }
if ( $_results.count -gt 1 ) {