Posts

Showing posts with the label PowerShell

PowerShell Script/Cmdlet: Get-UserAccountControlPolicy

Image
A PowerShell function that returns detailed information regarding how User Account Control is configured on the current system in a human-readable format. Installation Instructions: Determine where your local scripts directory is with the following command: ([IO.DirectoryInfo](Join-Path $Profile.CurrentUserCurrentHost ".." "Scripts")).FullName Create a new file within that directory and name it Get-UserAccountControlPolicy.ps1 . Copy and paste the contents below into that file and save it. function Get-UserAccountControlPolicy { [CmdletBinding( ConfirmImpact = 'Low', DefaultParameterSetName = 'HideStatusParameterSet', PositionalBinding = $false, SupportsPaging = $false, SupportsShouldProcess = $false )] [OutputType([Object[]])] [Alias('Get-UACPolicy')] param ( [Parameter(ParameterSetName = 'HideStatusParameterSet')] [Alias('AccountScope',...

PowerShell Script/Cmdlet: Get-NthRoot

Image
A PowerShell function that computes the principal nth root n^A of positive real number A. Installation Instructions: Determine where your local scripts directory is with the following command: ([IO.DirectoryInfo](Join-Path $Profile.CurrentUserCurrentHost ".." "Scripts")).FullName Create a new file within that directory and name it Get-NthRoot.ps1 . Copy and paste the contents below into that file and save it. function Get-NthRoot { $Phi 1.6180339887498948482045868384 Creates the variable $Phi within the Global scope for convenient access to the golden ratio whenever and wherever desired. .EXAMPLE $Semitone = Get-NthRoot -Radicand 2 -Degree 12 -Precision 5 PS > $NoteFreq = @{ 'C' = 16.35160; 'C#' = 17.32391; 'D' = 18.35405 >> 'D#' = 19.44544; 'E' = 20.60172; 'F' = 21.82676 >> 'F#' = 23.12465; 'G' = 24.49971;...

Managing PSStyle's File Extension Dictionary

Image
Documentation on PowerShell's experimental PSANSIRenderingFileInfo feature is understandably limited at the moment. This experiment was added in PowerShell 7.2. This feature adds the $PSStyle.FileInfo member and enables coloring of specific file types. $PSStyle.FileInfo.Directory - Built-in member to specify color for directories $PSStyle.FileInfo.SymbolicLink - Built-in member to specify color for symbolic links $PSStyle.FileInfo.Executable - Built-in member to specify color for executables. $PSStyle.FileInfo.Extension - Use this member to define colors for different file extensions. The Extension member pre-includes extensions for archive and PowerShell files. Using Experimental Features in PowerShell | Microsoft Docs Methods After some trial-and-error in a console, I found several methods offered by [System.Management.Automation.PSStyle+FileExtensionDictionary] that stand out: Add() Creates an extension with an associated decoration and appends it to the dicti...