Skip to content

Instantly share code, notes, and snippets.


Alain Assaf alainassaf

View GitHub Profile
alainassaf / open-WemConsole.ps1
Last active Feb 5, 2021
Script to open the Citrix WEM Console
View open-WemConsole.ps1
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
Optional string parameter. The WEM Infrastrucure server the WEM Console will connect to.
PS> open-WemConsole.ps1
Opens the WEM Console connected to the last WEM infrastrcuture server.
alainassaf / get-pixabayImage.ps1
Created Apr 20, 2020
Function to query and download a Pixabay Image
View get-pixabayImage.ps1
function get-pixabayImage {
param (
[parameter(Position = 0, Mandatory = $True )]
[Parameter(Mandatory = $true)]
[ValidateSet("backgrounds", "fashion", "nature", "science", "education", "feelings", "health", "people", "religion", "places", "animals", "industry", "computer", "food", "sports", "transportation", "travel", "buildings", "business", "music")]
alainassaf / deleteVM.ps1
Created Dec 7, 2018
Code to delete XenServer VM and its disks
View deleteVM.ps1
$vmtodelete = Get-XenVM | Where-Object {$_.is_a_snapshot -eq $false -and $_.is_a_template -eq $false -and $_.is_control_domain -eq $false -and $_.name_label -eq $virtualMachine}
if ($vmtodelete) {
if ($vmtodelete.power_state -eq "Halted") {
Write-Verbose "$virtualmachine is powered off. Deleting $virtualmachine from $xsn"
$vmtodelete.VBDs | Remove-XenVBD #Deletes attached disks
$vmtodelete | Remove-XenVM #Deletes VM
Get-XenSession -Server $_ | Disconnect-XenServer
Exit 0
} else {
Write-Warning "$virtualmachine is not powered off. Exiting script"
alainassaf / get-xsvmcount.ps1
Last active Jul 27, 2018
Getting, counting, saving
View get-xsvmcount.ps1
# Retrieve the information
$XenServerVMs = Get-XenVM | Where-Object {$_.is_a_snapshot -eq $false -and $_.is_a_template -eq $false -and $_.is_control_domain -eq $false -and $_.power_state -eq 'running'} | Select-Object name_label
$vmCount = $XenServerVMs.count
$objctxsrv = new-object System.Object
$objctxsrv | Add-Member -type NoteProperty -name XenServer -value $xsn
$objctxsrv | Add-Member -type NoteProperty -name 'VM Count' -value ($vmCount)
$finalout += $objctxsrv
# Disconnect from the XenServer pool
Get-XenSession -Server $_ | Disconnect-XenServer
alainassaf / get-xsvmcount.ps1
Created Jul 27, 2018
Switch to change to name
View get-xsvmcount.ps1
switch ($_) {
"" {$xsn = "XenServerPool1"; break}
"" {$xsn = "XenServerPool2"; break}
default {"UNKNOWN XENSERVER"; break}
alainassaf / get-xsvmcount.ps1
Last active Jul 27, 2018
Looping through XS Poolmasters
View get-xsvmcount.ps1
# Loop through list of hosts (poolmaster)
$xenserver_poolmaster | ForEach-Object {
# Connect to XenServer pool
Connect-XenServer -Server $_ -Creds $xenserver_credential -SetDefaultSession -NoWarnNewCertificates
alainassaf / showflow.ps1
Last active Mar 6, 2018
showflow example
View showflow.ps1
# *** START: ShowFlow *********************************************************
if ($ShowFlow) {
# Install GraphViz from the Chocolatey repo
#Register-PackageSource -Name Chocolatey -ProviderName Chocolatey -Location
Find-Package graphviz | Install-Package -ForceBootstrap
# Install PSGraph from the Powershell Gallery
Find-Module PSGraph | Install-Module
# Import Module PSGraph