This file contains hidden or 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-ImageFromHub { | |
<# | |
.SYNOPSIS | |
Find the docker image for the current Windows Server OS from Docker Hub. | |
Additionally it can also inspect the image and get its size (from all of its layers) | |
NOTE: This function does not download the docker image, just its metadata. | |
The -ShowSize switch requires the docker tool. | |
.EXAMPLE | |
Get-ImageFromHub -ShowSize |
This file contains hidden or 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-ProcessWithService { | |
<# | |
.SYNOPSIS | |
Get the processes along with the relevant service associated to each process (if any) | |
This is the equivalent to "tasklist /svc" cmd command. | |
.EXAMPLE | |
Get-ProcessWithService | where Service | select ProcessId,Name,Service | |
.NOTES | |
WMI Query Language (WQL) WHERE Clause | |
https://learn.microsoft.com/en-us/windows/win32/wmisdk/where-clause |
This file contains hidden or 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
# this hashtable is used on the extension name validation for the input | |
# it is also used to get the extension id | |
$script:VSCodeExtensions = @{ | |
'vscode-icons' = 'vscode-icons-team.vscode-icons' | |
powershell = 'ms-vscode.powershell' | |
csharp = 'ms-dotnettools.csdevkit' | |
terraform = 'hashicorp.terraform' | |
} | |
# Note: if this was a module, we could have this in a .psd1 file |
This file contains hidden or 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
# ENV variable | |
$env:COMPUTERNAME | |
# Note: this is limited to 15 characters | |
# native C++ | |
hostname.exe | |
# Note: this shows the full name <<===== | |
# environment class |
This file contains hidden or 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-ADCredential { | |
<# | |
.Synopsis | |
Verify Active Directory credentials | |
.EXAMPLE | |
Test-ADCredential -Username user1 -Password Secret01 | |
#> | |
[CmdletBinding(DefaultParameterSetName = 'PSCreds')] | |
[OutputType([Boolean])] |
This file contains hidden or 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 Resolve-AmazonArn { | |
<# | |
.SYNOPSIS | |
Parse an Amazon Resource Name (ARN) into its individual parts. | |
.EXAMPLE | |
'arn:aws:iam::111222333444:role/MyRole' | Resolve-AmazonArn | |
.EXAMPLE | |
Resolve-AmazonArn arn:aws:s3:::MyBucket/MyFolder/* | |
.EXAMPLE | |
Resolve-AmazonArn s3://MyBucket/MyFolder/MyFile.json |
This file contains hidden or 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-RunspaceJob { | |
<# | |
.SYNOPSIS | |
It runs a command on a timer, so it can abort the command if the timeout expires. | |
It can also run the command as a different user. | |
It allows the end-user to pass input parameters to the command. | |
.EXAMPLE | |
Start-RunspaceJob -Scriptblock { | |
$p1 = ' ' * 9 ; $p2 = ' ' * 18 | |
Write-Verbose "$p1 1 [V] Will do A" -Verbose |
This file contains hidden or 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-AmazonApiOperation { | |
<# | |
.SYNOPSIS | |
Show the relevant AWS API Operation for a given PowerShell command | |
.DESCRIPTION | |
This function comes handy when writing permissions for IAM roles. | |
Because you need to know the actions (as-in API operations) that you want to allow in the IAM policy. | |
.EXAMPLE | |
Get-Command -Noun EC2Tag | Get-AmazonApiOperation |
This file contains hidden or 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-PasswordComplexity { | |
<# | |
.SYNOPSIS | |
It checks if a password meets the minimum required password complexity | |
.EXAMPLE | |
Test-PasswordComplexity -Password 123asdASD -MinComplex 2 -MinLength 6 -MinUpper 2 -MinLower 2 -MinDigits 2 -MinSpecial 2 | |
Returns True. Because the password is more than 6 characters long. It is actually 9 characters long. | |
And it has more than 2 different character types. Namely it has lower, upper and numbers which are 3 different types. | |
And out of those character types is has the minimum number of characters required for each type. |
This file contains hidden or 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 Split-ByGroup { | |
<# | |
.SYNOPSIS | |
It will split an array into chunks and return a number of arrays based on a group size | |
.EXAMPLE | |
# first create a sample array (I'm using the RNG class here to do that) | |
$ArraySize = 160 | |
$Array = [byte[]]::new($ArraySize) | |
$rng = [Security.Cryptography.RandomNumberGenerator]::Create() | |
$rng.GetBytes($Array) |
NewerOlder