Skip to content

Commit

Permalink
v0.6.2 ready for release
Browse files Browse the repository at this point in the history
## 0.6.2 - 2020-05-14

* Miscellaneous
    * Fixed: `PSProfile.ADCompleters` plugin now correctly tab completes properties for `Get-ADComputer` and `Get-ADGroup`
    * Added: InitScripts, ScriptPaths, and Plugins now create a dynamic module per item for easier discovery of where the command came from.
    * Updated: `Get-PSProfileImportedCommands` logic so it pulls in commands from any module named `PSProfile.*`, which includes the changes to InitScripts, ScriptPaths, and Plugins where they are now loaded in as dynamic modules.
  • Loading branch information
scrthq committed May 14, 2020
1 parent 05c7cbc commit 7cbac81
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# PSProfile - ChangeLog

* [PSProfile - ChangeLog](#psprofile---changelog)
* [0.6.2 - 2020-05-14](#062---2020-05-14)
* [0.6.1 - 2019-11-04](#061---2019-11-04)
* [0.6.0 - 2019-11-02](#060---2019-11-02)
* [0.5.0 - 2019-10-08](#050---2019-10-08)
Expand All @@ -21,6 +22,13 @@

***

## 0.6.2 - 2020-05-14

* Miscellaneous
* Fixed: `PSProfile.ADCompleters` plugin now correctly tab completes properties for `Get-ADComputer` and `Get-ADGroup`
* Added: InitScripts, ScriptPaths, and Plugins now create a dynamic module per item for easier discovery of where the command came from.
* Updated: `Get-PSProfileImportedCommands` logic so it pulls in commands from any module named `PSProfile.*`, which includes the changes to InitScripts, ScriptPaths, and Plugins where they are now loaded in as dynamic modules.

## 0.6.1 - 2019-11-04

* Miscellaneous
Expand Down
47 changes: 41 additions & 6 deletions PSProfile/Classes/PSProfile.Classes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,17 @@ if ($env:AWS_PROFILE) {
'Verbose'
)
$sb = [scriptblock]::Create($this._globalize(([System.IO.File]::ReadAllText($i.FullName))))
.$sb
$newModuleArgs = @{
Name = "PSProfile.ScriptPath.$($i.BaseName)"
ScriptBlock = $sb
ReturnResult = $true
}
$this._log(
"'$($i.Name)' Importing dynamic ScriptPath module: $($newModuleArgs.Name)",
'InvokeScripts',
'Verbose'
)
New-Module @newModuleArgs | Import-Module -Global
}
catch {
$e = $_
Expand Down Expand Up @@ -754,7 +764,17 @@ if ($env:AWS_PROFILE) {
)
try {
$sb = [scriptblock]::Create($this._globalize($s.Value.ScriptBlock))
.$sb
$newModuleArgs = @{
Name = "PSProfile.InitScript.$($s.Key)"
ScriptBlock = $sb
ReturnResult = $true
}
$this._log(
"'$($s.Key)' Importing dynamic InitScript module: $($newModuleArgs.Name)",
'InvokeInitScripts',
'Verbose'
)
New-Module @newModuleArgs | Import-Module -Global
}
catch {
$this._log(
Expand Down Expand Up @@ -939,19 +959,34 @@ if ($env:AWS_PROFILE) {
}
foreach ($plugPath in $pathsToSearch) {
$fullPath = [System.IO.Path]::Combine($plugPath,"$($plugin.Name).ps1")
$paths = Get-ChildItem $plugPath -Filter "$($plugin.Name)*" | Where-Object {$_.Name -match "$($plugin.Name)\.psm*1$"}
if ($paths.Count -gt 1) {
$fullPath = $paths.FullName | Where-Object {$_ -match 'psm1$'} | Select-Object -First 1
}
else {
$fullPath = $paths.FullName | Select-Object -First 1
}
$this._log(
"'$($plugin.Name)' Checking path: $fullPath",
'LoadPlugins',
'Debug'
)
if (Test-Path $fullPath) {
$sb = [scriptblock]::Create($this._globalize(([System.IO.File]::ReadAllText($fullPath))))
if ($plugin.ArgumentList) {
.$sb($plugin.ArgumentList)
$newModuleArgs = @{
Name = "PSProfile.Plugin.$($plugin.Name -replace '^PSProfile\.')"
ScriptBlock = $sb
ReturnResult = $true
}
else {
.$sb
if ($plugin.ArgumentList) {
$newModuleArgs['ArgumentList'] = $plugin.ArgumentList
}
$this._log(
"'$($plugin.Name)' Importing dynamic Plugin module: $($newModuleArgs.Name)",
'LoadPlugins',
'Verbose'
)
New-Module @newModuleArgs | Import-Module -Global
$found = $fullPath
break
}
Expand Down
3 changes: 2 additions & 1 deletion PSProfile/Plugins/PSProfile.ADCompleters.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Register-ArgumentCompleter -CommandName 'Get-ADUser' -ParameterName 'Properties' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
@(
Expand Down Expand Up @@ -142,6 +141,7 @@ Register-ArgumentCompleter -CommandName 'Get-ADUser' -ParameterName 'Properties'
}

Register-ArgumentCompleter -CommandName 'Get-ADComputer' -ParameterName 'Properties' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
@(
'AccountExpirationDate'
'accountExpires'
Expand Down Expand Up @@ -243,6 +243,7 @@ Register-ArgumentCompleter -CommandName 'Get-ADComputer' -ParameterName 'Propert
}

Register-ArgumentCompleter -CommandName 'Get-ADGroup' -ParameterName 'Properties' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
@(
'AddedProperties'
'CanonicalName'
Expand Down
2 changes: 1 addition & 1 deletion PSProfile/Public/Meta/Get-PSProfileImportedCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Get-PSProfileImportedCommand {
$Command
)
Begin {
$commands = Get-Command -Module PSProfile | Where-Object {$_.Name -notin (Get-Module PSProfile).ExportedCommands.Keys}
$commands = Get-Command -Module PSProfile.* #| Where-Object {$_.Name -notin (Get-Module PSProfile).ExportedCommands.Keys}
}
Process {
if ($PSBoundParameters.ContainsKey('Command')) {
Expand Down

0 comments on commit 7cbac81

Please sign in to comment.