AKPT.psm1
<#
# AKPT-Module Import Script Code der beim Laden/Entladen des Modules AKPT ausgeführt wird. - **Hashtags** Module UserModule .PSM1 - **Version** 2020.01.14 #> #region Prolog [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalFunctions', '')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] param() Set-StrictMode -Version Latest $ModuleBasePath = Split-Path -Path $PSCommandPath -Parent #endregion #region Public Cmdlets-Code ausführen Get-ChildItem "$PSScriptRoot\Public\*.ps1" | ForEach-Object { . $_.FullName } #endregion #region Host-Prompt Anpassungen Get-Content -Path Function:\prompt | New-Variable -Name promptBackup -Scope Global -Option ReadOnly -Force { $lastCmd = Get-History -Count 1 if ($null -ne $lastCmd) { $timeSpan = $lastCmd.EndExecutionTime - $lastCmd.StartExecutionTime "[ {0}h {1}m {2}s {3}ms ] {4}$('>' * ($nestedPromptLevel + 1)) " -f $timeSpan.Hours, $timeSpan.Minutes, $timeSpan.Seconds, $timeSpan.Milliseconds, $executionContext.SessionState.Path.CurrentLocation } else { "[ 0 ms ] $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) " } } | Set-Content -Path Function:\prompt #endregion #region Typen-Erweiterungen $code = { Add-Type -AssemblyName "System.Windows.Forms" $propertyGrid = New-Object -TypeName "System.Windows.Forms.PropertyGrid" $propertyGrid.Dock = [System.Windows.Forms.DockStyle]::Fill $propertyGrid.PropertySort = [System.Windows.Forms.PropertySort]::Alphabetical $propertyGrid.CanShowVisualStyleGlyphs = $true $propertyGrid.CommandsVisibleIfAvailable = $true $propertyGrid.HelpVisible = $true $propertyGrid.ToolbarVisible = $true $propertyGrid.SelectedObject = $this $window = New-Object -TypeName "System.Windows.Forms.Form" $window.Text = $this.ToString() $window.Size = New-Object -TypeName "System.Drawing.Size" -ArgumentList @(600, 800) $window.TopMost = $true $window.Controls.Add($propertyGrid) $window.ShowDialog() | Out-Null } Update-TypeData -MemberType "ScriptMethod" -MemberName "ShowObject" -Value $code -TypeName "System.Object" -Force #endregion #region Import-Epilog & "$ModuleBasePath\Private\Scripts\TipOfTheDay.ps1" #endregion #region Aufräumarbeiten (Remove-Module) $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { Remove-TypeData -TypeName System.Object -ErrorAction Ignore $Global:promptBackup | Set-Content -Path Function:\prompt -Force Remove-Variable -Name promptBackup -Scope Global -Force -ErrorAction Ignore Remove-Variable -Name ModuleBasePath -Scope Global -Force -ErrorAction Ignore } #endregion |