Skip to content

Instantly share code, notes, and snippets.

View alainassaf's full-sized avatar

Alain Assaf alainassaf

View GitHub Profile
<#
.SYNOPSIS
Reviews and evenly distributes VDA's within a Citrix Hypervisor pool.
.DESCRIPTION
Reviews and evenly distributes VDA's within a Citrix Hypervisor pool.
.PARAMETER XenServer_poolmaster
Mandatory string parameter. IP of the Citrix Hypervisor pool master to optimize.
.PARAMETER XenServer_networkname
Mandatory string parameter. Network name of the Citrix Hpervisor pool's management network
.PARAMETER XenServer_SRName
@alainassaf
alainassaf / get-applockerlogs.ps1
Last active September 15, 2022 16:04
get-applockerlogs.ps1
<#
.SYNOPSIS
Iterates through list of servers or a single server and retrieves AppLocker Event logs. Can filter the results by log level.
.DESCRIPTION
Iterates through list of servers or a single server and retrieves AppLocker Event logs. Can filter the results by log level. The data returned is from the last 24 hours.
.PARAMETER Computer
Optional string parameter. Single server to query applocker logs. If blank, script queries local system. Parameter set=Computer
.PARAMETER ComputerList
Mandatory string parameter. List of servers to query applocker logs. If blank, script queries local system. Parameter set=ComputerList
.PARAMETER LogLevel
@alainassaf
alainassaf / My VSCode User Snippets for PowerShell
Created January 28, 2022 13:20
My VSCode USer snippets for PowerShell
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
<#
.SYNOPSIS
Searches Citrix sessions that are running a certain published application and stops it if a session is idle for a certain time.
.DESCRIPTION
Searches Citrix sessions that are running a certain published application and stops it if a session is idle for a certain time. Logs are generated in the same directory as the script runs.
.PARAMETER deliverycontroller
Mandatory string parameter. Which Citrix Delivery Controller (farm) to query for session.
.PARAMETER pubApp
Mandatory string parameter. Which published application to stop.
.PARAMETER idletime
@alainassaf
alainassaf / open-WemConsole.ps1
Last active February 5, 2021 00:59
Script to open the Citrix WEM Console
<#
.SYNOPSIS
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
.DESCRIPTION
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
.PARAMETER WEMServer
Optional string parameter. The WEM Infrastrucure server the WEM Console will connect to.
.EXAMPLE
PS> open-WemConsole.ps1
Opens the WEM Console connected to the last WEM infrastrcuture server.
@alainassaf
alainassaf / get-pixabayImage.ps1
Created April 20, 2020 15:29
Function to query and download a Pixabay Image
function get-pixabayImage {
[CmdletBinding()]
param (
[parameter(Position = 0, Mandatory = $True )]
[ValidateNotNullOrEmpty()]
[string]$query,
[Parameter(Mandatory = $true)]
[ValidateSet("backgrounds", "fashion", "nature", "science", "education", "feelings", "health", "people", "religion", "places", "animals", "industry", "computer", "food", "sports", "transportation", "travel", "buildings", "business", "music")]
$category,
@alainassaf
alainassaf / deleteVM.ps1
Created December 7, 2018 15:27
Code to delete XenServer VM and its disks
$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
alainassaf / get-xsvmcount.ps1
Last active July 27, 2018 14:09
Getting, counting, saving
# 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
alainassaf / get-xsvmcount.ps1
Created July 27, 2018 14:05
Switch to change to name
switch ($_) {
"192.168.50.1" {$xsn = "XenServerPool1"; break}
"192.168.50.2" {$xsn = "XenServerPool2"; break}
default {"UNKNOWN XENSERVER"; break}
}
@alainassaf
alainassaf / get-xsvmcount.ps1
Last active July 27, 2018 14:03
Looping through XS Poolmasters
# Loop through list of hosts (poolmaster)
$xenserver_poolmaster | ForEach-Object {
# Connect to XenServer pool
Connect-XenServer -Server $_ -Creds $xenserver_credential -SetDefaultSession -NoWarnNewCertificates