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
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 { |
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-ValueFromPipeline { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[string] | |
$MyString, | |
[switch] | |
$MySwitch) | |
begin { |
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
$table = @{ | |
"UPPER" = "UPPER"; | |
"lower" = "lower"; | |
} | |
#$table["UPPER"] | |
#$table["upper"] |
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
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 _ { |
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
$c=1 | |
1..20|%{Write-Host $c | |
$i=0 | |
$a=@($c[0]) | |
while($i -lt $_){$a+=($c[$i]+$c[++$i])} | |
$c=$a} |
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 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 |
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-FileInfo { | |
[CmdletBinding(DefaultParameterSetName='Local')] | |
param ( | |
# The Path parameter takes an array of strings to query. Pipe away if desired | |
[Parameter(ValueFromPipeline=$true)] | |
[Parameter(ParameterSetName = 'Local')] | |
[Parameter(ParameterSetName = 'Remote')] | |
[string[]] | |
$Path, | |
# The ComputerName parameter takes several computernames and executes the Get-FileInfo command against them |
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
param ($crypto = @" | |
P k T r 2 s z 2 * c F - | |
r a z 7 G u D 4 w 6 U # | |
g c t K 3 E @ B t 1 a Y | |
Q P i c % 7 0 5 Z v A e | |
W 6 j e P R f p m I ) H | |
y ^ L o o w C n b J d O | |
S i 9 M b e r # ) i e U | |
* f 2 Z 6 M S h 7 V u D | |
5 a ( h s v 8 e l 1 o W |
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 Remove-AdminCount | |
{ | |
[CmdletBinding()] | |
param ($Samaccountname) | |
if (!$(Get-Module activedirectory)){import-module activedirectory} | |
try | |
{ | |
$User = Get-ADUser $Samaccountname -Properties Admincount | |
if ($User.Admincount -eq 1) | |
{ |
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
Out-Default -InputObject @{Source=$env:COMPUTERNAME;Target=$env:COMPUTERNAME} -PipelineVariable ST | foreach {compare-object (Get-WindowsFeature -ComputerName $ST['Source']).where{$_.installed} (Get-WindowsFeature -ComputerName $ST['Target']).where{$_.installed}} | ForEach-Object {if ($_.SideIndicator -eq '<='){Install-WindowsFeature -Name $_.InputObject.Name -ComputerName $ST['Target']} elseif ($_.SideIndicator -eq '=>') {Uninstall-WindowsFeature -Name $_.InputObject.Name -ComputerName $ST['Target']}} |
NewerOlder