Skip to content

Instantly share code, notes, and snippets.

View vScripter's full-sized avatar
👨‍💻

Kevin Kirkpatrick vScripter

👨‍💻
View GitHub Profile
@vScripter
vScripter / Set-ConsoleWindowTitle.ps1
Last active August 29, 2015 14:16
Set-ConsoleWindowTitle - Set the PowerShell console window title to a custom message or a custom 'default' message.
function Set-ConsoleWindowTitle {
[cmdletbinding()]
param (
[parameter(Mandatory = $true,
Position = 0,
ParameterSetName = 'Default')]
[validateset("Default", "Custom")]
[string]$MessageType,
@vScripter
vScripter / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function Get-OrderedVM {
[cmdletbinding()]
param (
[parameter(Mandatory = $true, Position = 0)]
[alias('VM')]
[String[]]$Name
)
$finalResult = @()
function Test-Function {
[cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param(
$ComputerName = $env:computername
)
PROCESS {
if($PSCmdlet.ShouldProcess($ComputerName,'Gathering Services')) {
@vScripter
vScripter / Remove-UserProfile.ps1
Created March 31, 2015 15:33
Script to remove a selected AD user profile from a system or multiple systems
[cmdletbinding(PositionalBinding = $true)]
param (
[parameter(Mandatory = $true,
Position = 0)]
[System.String[]]$ComputerName,
[parameter(Mandatory = $true,
Position = 1,
HelpMessage = "Enter the account name in 'DOMAIN\USERNAME' notation ")]
[System.String]$UserName,
<#
.SYNOPSIS
Retrieves all logged on users from a local or remote system
.DESCRIPTION
RRetrieves all logged on users from a local or remote system.
This script/function parses the output from the 'qwinsta' command, and formats it into a proper PSObject
.INPUTS
System.String
<#
.SYNOPSIS
This function will log off the specified user/session, based on session ID
.DESCRIPTION
This function will log off the specified user/session, based on session ID.
It was written to accept pipeline input from the Get-LoggedOnUser function, but it can also be run as a stand-alone function, if desired.
.PARAMETER ComputerName
Name of computer/s
function Start-LogLyncAvailability {
[CmdletBinding(
SupportsShouldProcess = $false,
ConfirmImpact = "None",
DefaultParameterSetName = "")]
param (
[Parameter(
Position = 0,
ValueFromPipeLine = $false,
Mandatory = $true,
# No need for the code on the next line, just put the functions in this script; you run into scoping issues dot sourcing these functions, the way they are written
#. .\func1.ps1
#region functions
function Start-LogLyncAvailability {
[CmdletBinding(
SupportsShouldProcess = $false,
ConfirmImpact = "None",
DefaultParameterSetName = "")]
@vScripter
vScripter / New-Object.ps1
Created April 13, 2015 03:44
Creating new object
$queryItems = Get-Service | Select ServiceName,Status
foreach ($service in $queryItems) {
# clear on each iteration
$objSvc = @()
# create properties and assign values; in this example I am using strong types to define the type of value
# the property will return
$objSvc = [PSCustomObject] @{
Service = [System.String]$service.ServiceName