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-DurationText { | |
<# | |
.SYNOPSIS | |
Get the elapsed duration as a string, in a number of different formats | |
.EXAMPLE | |
Get-DurationText -Duration ([timespan]::FromDays(2)) | |
2d 0hr | |
#> | |
[CmdletBinding(DefaultParameterSetName='Timespan')] | |
[OutputType([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
# I wrote these notes in Sep-2024 | |
# AES 128 and 256 bits | |
# Without using .NET Streams | |
## Initial Input | |
[string]$PlainText = 'this is a test message' | |
[string]$Password = 'SampleSecret' |
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-ArgumentCompleter { | |
<# | |
.SYNOPSIS | |
Get the argument completers that are registered in the current session (if any) | |
.EXAMPLE | |
Import-Module PowerShellGet | |
Get-ArgumentCompleter | |
shows the argument completers that are registered from the PowerShellGet module | |
.EXAMPLE |
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-AzRequestInfo { | |
<# | |
.SYNOPSIS | |
It gets the web request details from an azure command. | |
IMPORTANT: | |
The azure command must be run with the -Debug switch AND you need to collect the debug stream | |
.EXAMPLE | |
$ResGrp = Get-AzResourceGroup -Name mysub -Location eastus2 -Debug 5>&1 | |
Get-AzRequestInfo $ResGrp |
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
# Convert to/from Hex | |
### From Byte array to Hex String | |
$bytes = [byte[]](10,20,30,40) | |
# a) via .ToString() method | |
$bytes.ForEach({$_.ToString('x2')}) -join '' |
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-TaskManager { | |
<# | |
.SYNOPSIS | |
Gets the CPU, memory and disk utilization of the top X processes (by default 10) | |
The command can also query remote computers. | |
Sorting works based on the processes with the highest CPU utilization. | |
.DESCRIPTION | |
Very briefly, these are the steps taken by this command as part of its process workflow: | |
- Load an internal function, the Get-TaskUsage | |
- Remote to one or more computers with Invoke-Command and pass in the internal function |
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
## Parameter Sets Examples | |
# Example #1 | |
# Choose 1 or 2 out of 2 | |
# order is not important | |
<# Combinations: 3 in total |
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-WindowsVersion { | |
<# | |
.SYNOPSIS | |
It provides the equivalent information to winver.exe | |
.EXAMPLE | |
Get-WindowsVersion | |
#> | |
[cmdletbinding()] | |
param () |
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-WinUpdate { | |
<# | |
.SYNOPSIS | |
Get a list of all the windows updates on the system | |
Note: This function will only show the updates that have a KB ID | |
Any hotfixes without an update ID won't be included in the results | |
.EXAMPLE | |
Get-WinUpdate | where Title -like '*cumulative update for windows*' | |
.EXAMPLE |
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-RuntimeDiagnostics { | |
<# | |
.SYNOPSIS | |
Collect the count and memory size of the .net objects used by a process | |
.DESCRIPTION | |
Collect the count and memory size of the .net objects used by a process | |
This function is using the Microsoft.Diagnostics.Runtime .NET library from nuget: | |
https://www.nuget.org/packages/Microsoft.Diagnostics.Runtime |
NewerOlder