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-HMACHash { | |
[CmdletBinding()] | |
param ( | |
# Message to geneate a HMAC hash for | |
[Parameter(Mandatory = $true, | |
Position = 0, | |
ParameterSetName = "Default", | |
ValueFromPipelineByPropertyName = $true)] | |
[ValidateNotNullOrEmpty()] | |
[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 | |
Move Azure VM to an Availability Set | |
.DESCRIPTION | |
Deallocates and redeploys an Azure VM to move it into a new Availbility Set. | |
This Will create the Availability Set if not found. | |
.EXAMPLE | |
PS C:\> ./Move-AzVmToNewAvailabilitySet.ps1 -resourceGroup "prismrbs-prod-eus-rg" -vmName "di-vm0" -newAvailSetName "di-vmSet" | |
Explanation of what the example does | |
.INPUTS |
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 Connect-Office365 | |
{ | |
[CmdletBinding()] | |
[Alias()] | |
[OutputType([void])] | |
Param | |
( | |
# Param1 help description | |
[Parameter(Position=0)] | |
[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
function Convert-SecureString { | |
[CmdletBinding()] | |
param ( | |
# SecureString | |
[Parameter(Mandatory=$true)] | |
[SecureString] | |
$SecureString | |
) | |
Return ( [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)) ) |
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 | |
Use XKPasswd.net to generate random passwords | |
.DESCRIPTION | |
Use XKPasswd.net and the XKCD strong password algorithm to generate | |
easy to remember high entropy passwords | |
.EXAMPLE | |
# Generate 4 passwords with 4 words each | |
New-XKPasswd -Count 4 -Words 4 |
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
# Check if AD User Exist: Method 1 | |
[bool] (Get-ADUser -Filter {SamAccountName -eq "NonExistingADUser" }) | |
# Check if AD User Exist: Method 2 | |
## supports all valid identity formats | |
function Test-ADUser { | |
[CmdletBinding()] | |
param ( | |
# Identity | |
[Parameter(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
function Enumerate-ConsoleColors { | |
[CmdletBinding()] | |
param ( | |
# Print Example Switch | |
[Parameter(Mandatory=$false)] | |
[Alias("Example","ex","print")] | |
[Switch] | |
$PrintExamples=$false | |
) |
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
# Genereate Dummy array of numbers (does not matter that they are sequental) | |
$array = 1..20 | |
# Get group size | |
$size = (($array.Count / 5 )) | |
# Create empty array to populate with multidemensional array | |
$rules = @() | |
# For 0 to count of array. |
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
# Working with a [System.IO.FileInfo] Object | |
## Get file object into variable | |
PS C:\DATA> $file = Get-ChildItem C:\DATA\test.xls | |
## Full path name | |
PS C:\DATA> $file.FullName | |
C:\DATA\test.xls | |
## Filename including extension | |
PS C:\DATA> $file.Name |
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
param([string]$SQLServerName="localhost") | |
# Load needed assemblies | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null; | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMOExtended")| Out-Null; | |
# Simple to function to write html pages | |
function writeHtmlPage | |
{ | |
param ($title, $heading, $body, $filePath); |