This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-ConsoleWindowTitle { | |
[cmdletbinding()] | |
param ( | |
[parameter(Mandatory = $true, | |
Position = 0, | |
ParameterSetName = 'Default')] | |
[validateset("Default", "Custom")] | |
[string]$MessageType, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-OrderedVM { | |
[cmdletbinding()] | |
param ( | |
[parameter(Mandatory = $true, Position = 0)] | |
[alias('VM')] | |
[String[]]$Name | |
) | |
$finalResult = @() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-Function { | |
[cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] | |
param( | |
$ComputerName = $env:computername | |
) | |
PROCESS { | |
if($PSCmdlet.ShouldProcess($ComputerName,'Gathering Services')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-LogLyncAvailability { | |
[CmdletBinding( | |
SupportsShouldProcess = $false, | |
ConfirmImpact = "None", | |
DefaultParameterSetName = "")] | |
param ( | |
[Parameter( | |
Position = 0, | |
ValueFromPipeLine = $false, | |
Mandatory = $true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |