Join-String dependency fix + Get-Path cleanup
If Join-String is missing, the 'string' module, if not existing will be installed and then imported. Get-Path produced an error when used with wildcard, fixed it with string substituation. Get-Path would output wildcard string when expansion didn't match, now output will be blank.
This commit is contained in:
parent
4da3726760
commit
b5b5702b17
2 changed files with 15 additions and 1 deletions
12
base/profile.d/Join-String.ps1
Normal file
12
base/profile.d/Join-String.ps1
Normal file
|
@ -0,0 +1,12 @@
|
|||
if( -not (Get-Command Join-String -ErrorAction SilentlyContinue) ) {
|
||||
if( -not (Get-Module -ListAvailable -Name "string") ) {
|
||||
Write-Warning 'Join-String Command is missing, attempting to install stirng module'
|
||||
$local:moduleScope = "CurrentUser"
|
||||
if( Test-IsAdmin ) { $moduleScope = "AllUsers" }
|
||||
Install-Module -Name "string" -Scope $moduleScope -AllowClobber -ErrorAction SilentlyContinue
|
||||
}
|
||||
if( -not (Get-Module -ListAvailable -Name "string") ) {
|
||||
Write-Error "Failed to locate/install the module 'string'"
|
||||
}
|
||||
Import-Module -Name "string" -Cmdlet "Join-String"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue