Skip to content

Instantly share code, notes, and snippets.

View Sarafian's full-sized avatar

Alex Sarafian Sarafian

View GitHub Profile
@Sarafian
Sarafian / Get-ISHCMWebSession.ps1
Created April 10, 2017 07:44
Access ISHCM from PowerShell
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 March 30, 2017 06:34
Get random string PowerShell
function GetRandomString([int]$length){
-join ((65..90) + (97..122) | Get-Random -Count $length | % {[char]$_})
}
@Sarafian
Sarafian / Get-AWSCloudFormationSamples.ps1
Last active January 16, 2017 09:31
Download the AWS cloud formation samples in both JSON and AWS format
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
#Requires -RunAsAdministrator
<#
.Synopsis
Creates a new Hyper-V instance from a named template.
.DESCRIPTION
Imports an existing Hyper-V export into a new instance, set-up the local client host/ip resoltution and generate bootstrapping powershell script.
.PARAMETER OSVersion
The code name for operating system
.PARAMETER VMName
@Sarafian
Sarafian / Invoke-CommandWrap.ps1
Last active December 18, 2016 16:32
PowerShell - InvokeCommand local or remote
<#
.SYNOPSIS
Wraps the Invoke-Command to seamlessy execute script blocks remote or local
.DESCRIPTION
Invoke-Command does not provide a transparent method to execute script blocks locally or remotely without conditions. This limited wrapper commandlet does this.
Every blocked is wrapped with logging statements
.PARAMETER ScriptBlock
The script block
.PARAMETER BlockName
Name of the block. This is for logging purposes.
@Sarafian
Sarafian / Show-ModuleVersion.ps1
Created December 1, 2016 10:24
Show powershell module's (loaded and available) organized by Name, Version and Location
<#
.Synopsis
Reports modules
.DESCRIPTION
Reports modules
.EXAMPLE
Show-ModuleVersion
.EXAMPLE
Show-ModuleVersion -ListAvailable
.EXAMPLE
@Sarafian
Sarafian / Reset-PrefixedTitle.ps1
Last active October 22, 2016 12:19
Set/Reset a prefix on the PowerShell's Console Window title
<#
.Synopsis
Reset the window title of the console
.DESCRIPTION
Reset the window title of the console
.EXAMPLE
Reset-PrefixedTitle
#>
function Reset-PrefixedTitle
{
@Sarafian
Sarafian / Compare-WindowsFeatureName.ps1
Last active October 22, 2016 12:19
With this script you can compare and get a report for the windows feature names between two different versions of Windows Server.
param(
[Parameter(Mandatory=$true)]
[string]$NewWindowsServerVersionComputer,
[Parameter(Mandatory=$true)]
[string]$OldWindowsServerVersionComputer
)
# Process new windows server version
$featuresOnNew=Get-WindowsFeature -ComputerName $NewWindowsServerVersionComputer
$availableOnNew=$featuresOnNew|Where-Object -Property "InstallState" -EQ "Available"
$installedNew=$featuresOnNew|Where-Object -Property "InstallState" -EQ "Installed"
@Sarafian
Sarafian / Compare-SystemModuleWithGallery.ps1
Created October 14, 2016 11:10
Compare PowerShell system module with their PowerShell gallery counterparts
<#
.Synopsis
Compares system modules with available ones on powershell gallery
.DESCRIPTION
Compares system modules with available ones on powershell gallery
.EXAMPLE
Compare-SystemModuleWithGallery
.Link
http://mikefrobbins.com/2016/06/09/update-manually-installed-powershell-modules-from-the-powershell-gallery/
#>
@Sarafian
Sarafian / Format-Compare.ps1
Created September 2, 2016 09:16
A cmdlet to format the output of PowerShell's Compare-Object cmdlet.
<#
.Synopsis
Formats the output of Compare-Object for even results
.DESCRIPTION
When the compared set has even entries use this commandlet to promote the output Compare-Object to Name,Original,Changed using the SideIndicator
.PARAMETER Compare
The output of Compare-Object
.PARAMETER PathAsName
The path to use to create the Name column in the output
.EXAMPLE