Skip to content

Instantly share code, notes, and snippets.

View Agazoth's full-sized avatar

Axel B. Andersen Agazoth

View GitHub Profile
@Agazoth
Agazoth / GetFileReport.ps1
Last active March 6, 2020 16:50
Generates a usage report on a given folder
# This script generates a report containing the nessesary information about Size, LastChangeDate, LastReadDate on any given share
# The script needs to run locally on the server to optimize speed
param ([System.IO.DirectoryInfo]$Path, [switch]$SkipUnicode)
if (!$Path.Exists){
Write-Warning "$($path.FullName) not found!"
break
}
#Add Unicode switch
$c=1
1..20|%{Write-Host $c
$i=0
$a=@($c[0])
while($i -lt $_){$a+=($c[$i]+$c[++$i])}
$c=$a}
Import-Module posh-git
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`nPS'
function Get-Access {Get-AzContext -ListAvailable | Sort-Object account | Out-ConsoleGridView | Set-AzContext}
function Get-Subscription {Get-AzSubscription | Sort-Object Name | Out-ConsoleGridView | Select-AzSubscription}
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
function _ {
$table = @{
"UPPER" = "UPPER";
"lower" = "lower";
}
#$table["UPPER"]
#$table["upper"]
@Agazoth
Agazoth / Test-ValueFromPipeline.ps1
Last active February 1, 2025 06:56
ValueFromPipeline
function Test-ValueFromPipeline {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[string]
$MyString,
[switch]
$MySwitch)
begin {
@Agazoth
Agazoth / TabCompletion.ps1
Last active April 13, 2025 12:48
Tab completion
Register-ArgumentCompleter -CommandName 'Get-Models' -ParameterName 'Model' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParams)
if ($wordToComplete -notmatch ':') {
$completionResults = 'openai', 'google', 'github', 'azureopenai', 'azure', 'azureopenai'
$completionResults | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new("$($_):", $_, 'ParameterValue', "Provider: $_")
}
}
else {