Skip to content

Instantly share code, notes, and snippets.

View Sarafian's full-sized avatar

Alex Sarafian Sarafian

View GitHub Profile
@Sarafian
Sarafian / Export-ModuleDocumentation.ps1
Created January 16, 2017 12:06
Export a module's documentation in markdown
#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 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
@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 / 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/
#>
#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 / 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 / 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
@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 / Toggle-Preference.ps1
Last active August 24, 2016 09:21
Toggle Debug and Verbose preference in PowerShell with shortcut keys. Add the script to your Microsoft.PowerShell_profile.ps1
Set-PSReadlineKeyHandler -Chord "Ctrl+1" -BriefDescription 'Toggle $DebugPreference' -Description 'Toggle $DebugPreference between Continue and SilentlyContiinue' -ScriptBlock {
if($DebugPreference -eq 'Continue')
{
Write-Debug "Setting DebugPreference=SilentlyContinue"
Set-Variable -Name DebugPreference -Value "SilentlyContinue" -Scope Global -Force
return
}
if($DebugPreference -eq 'SilentlyContinue')
{
Set-Variable -Name DebugPreference -Value "Continue" -Scope Global -Force
@Sarafian
Sarafian / Disconnect-RemoteSessions.ps1
Last active June 15, 2018 12:21
This scripts uses the quser to scan for session on a remote computer and then rwinsta to disconnect it
<#
.Synopsis
Disconnects your user from remote computers
.DESCRIPTION
This scripts uses the quser to scan for session on a remote computer and then rwinsta to disconnect it
.NOTES
.LINK