Skip to content

Instantly share code, notes, and snippets.

Alex Sarafian Sarafian

  • Belgium
Block or report user

Report or block Sarafian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Sarafian
Sarafian / Filtering.ps1
Created Apr 21, 2019
Samples for tweet asking for name inspiration
View Filtering.ps1
<# Goal
In between null and arrays need to be transparently resolved
Filter an in memory typed structure generated from the followign xml
example expression dataElementsMaster.dataElementsIndiv.serviceRequest.ssr.type -eq CTCE
instead of
$pnrRetrieveResponse.dataElementsMaster.dataElementsIndiv | Where-Object {
($_.serviceRequest -ne $null) -and
($_.serviceRequest.ssr -ne $null) -and
($_.serviceRequest.ssr.type -eq "CTCE")
}
@Sarafian
Sarafian / Disconnect-RemoteSessions.ps1
Created May 10, 2018
Disconnect/Terminate remote sessions
View Disconnect-RemoteSessions.ps1
<#
.Synopsis
Disconnects your user from remote computers
.DESCRIPTION
This scripts uses the quser and qwinsta to scan for session on a remote computer and then rwinsta to disconnect it
.NOTES
.LINK
@Sarafian
Sarafian / New-RandomPassword.ps1
Last active May 2, 2017
Generate new random password with PowerShell
View New-RandomPassword.ps1
function New-RandomPassword
{
param(
[Parameter(Mandatory=$false)]
[int]$Length=8
)
begin {
}
@Sarafian
Sarafian / Test-PesterInvocation.ps1
Created Apr 27, 2017
Check if powershell code is executed as part of a Pester test
View Test-PesterInvocation.ps1
function Test-PesterInvocation {
$commandStack=Get-PSCallStack | Select-Object -ExpandProperty Command
#region Render
<#
for($i=$commandStack.Count-1;$i -ge 0;$i--)
{
$prefix="+".PadRight($commandStack.Count-1-$i,'-')
Write-Host ($prefix+$commandStack[$i])
}
@Sarafian
Sarafian / Start-MyRemoteDesktopConnection.ps1
Created Apr 11, 2017
Start PowerShell ISE or execute scripts as if the Windows System account was
View Start-MyRemoteDesktopConnection.ps1
<#
.Synopsis
Starts a remote desktop connection
.DESCRIPTION
Starts a remote desktop connection
.EXAMPLE
Start-MyRemoteDesktopConnection
#>
function Start-MyAsSystem
{
@Sarafian
Sarafian / Get-ISHCMWebSession.ps1
Created Apr 10, 2017
Access ISHCM from PowerShell
View Get-ISHCMWebSession.ps1
Function Get-ISHCMWebSession {
param (
[Parameter(Mandatory=$true)]
[string]$DeploymentName,
[Parameter(Mandatory=$false)]
[PSCredential]$Credential=$null
)
$deployment=Get-ISHDeployment -Name $DeploymentName
$deploymentParameters=Get-ISHDeploymentParameters -ISHDeployment $DeploymentName
@Sarafian
Sarafian / Get-RandomString.ps1
Created Mar 30, 2017
Get random string PowerShell
View Get-RandomString.ps1
function GetRandomString([int]$length){
-join ((65..90) + (97..122) | Get-Random -Count $length | % {[char]$_})
}
@Sarafian
Sarafian / Docker-Prune.txt
Last active May 3, 2018
How to remove unused Docker containers and images. Copy from comment in [gist](https://gist.github.com/ngpestelos/4fc2e31e19f86b9cf10b#gistcomment-1940551)
View Docker-Prune.txt
docker container prune # Remove all stopped containers
docker volume prune # Remove all unused volumes
docker image prune # Remove unused images
docker system prune # All of the above, in this order: containers, volumes, images
@Sarafian
Sarafian / Export-ModuleDocumentation.ps1
Created Jan 16, 2017
Export a module's documentation in markdown
View Export-ModuleDocumentation.ps1
#requires -module platyPS
<#
.SYNOPSIS
Export a module's documentation in markdown.
.DESCRIPTION
Export a module's documentation in markdown.
@Sarafian
Sarafian / Get-AWSCloudFormationSamples.ps1
Last active Jan 16, 2017
Download the AWS cloud formation samples in both JSON and AWS format
View Get-AWSCloudFormationSamples.ps1
param(
[Parameter(Mandatory=$false)]
[ValidateSet("ap-northeast-1","ap-northeast-2","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","eu-central-1","eu-west-1","eu-west-2","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2")]
[string]$Region="eu-west-1",
[Parameter(Mandatory=$false)]
[string]$OutputPath="$env:USERPROFILE\Documents\AWSCloudFormation-samples-json-yaml"
)
Set-StrictMode -Version latest
$rubyPath=& "C:\Windows\System32\where.exe" ruby 2>&1
You can’t perform that action at this time.