For generic PowerShell questions you can use the community slack http://slack.poshcode.org/
I have question for the scripting pros :-)
Is there a way to propagate $Verbose and $Debug automatically to a function imported from a different module?
I know there is no such thing like 'Import-Module -Scope Current' but maybe some has some tricks how to achieve this like fiddling with the session state or something like that or has written a cool cmdlet to achieve this?
This is own of the most annoying problem I have with PS and the organization of me modules. I've searched the interweb already and have'nt found much except some people walking the stack trace upwards.
Also i've also read $debug should be propagated which i can't reproduce with PS 7.1 at least.
@vexx32 Yes... i'm sure that there are (technical) reasons for this kind of isolation of modules but it is completely opposite to my expectations :-)
I't fiddling around with code like this:
function _inherit_verbose_preference {
$verbose = (Get-PSCallStack | Where-Object { $null -ne $_.InvocationInfo.BoundParameters.Verbose } | Select-Object -First 1).InvocationInfo.BoundParameters.Verbose
if($verbose) {
Set-Variable -Name "VerbosePreference" -Scope 1 -Value "Continue"
}
}but have not achieved a satisfying 'modus operandi' with this ... It only works in some situations
object. The value must be either a string that can be typecast to regex or a regex value. So I have [ValidateScript({$regexMatchTitle -is [string] -and ([regex]$regexMatchTitle -ne $null) -or $regexMatchTitle -is [regex]})]. This works when I test it outside the function, but not for real. When I try to call the function with $regexMatchTitle set to either '^race' or [regex]'^race', I get an error that the validation script returned a value other than True.
$_ would work there.
$_ is a maximum and I want to make sure that the corresponding minimum parameter, if specified, is less?
$PSBoundParameters?
$NormalRange = 1..10
$Id10tRange = 10..1
$Id10tRange | Sort-Object
Write-Output -InputObject 'Now for something completely different'
$NormalRange | Sort-Object
..5 or 5.., but those are syntax errors.
--playlist-start and --playlist-end.
@Aprazeth: They do have a --playlist-items. It's described as shown below:
Playlist video items to download. Specify indices of the videos in the playlist separated by commas like:
--playlist-items 1,2,5,8if you want to download videos indexed 1, 2, 5, 8 in the playlist. You can specify range:--playlist-items 1-3,7,10-13, it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13.
$PSBoundParameters? Do I put ? on the parameter type? In this case, the optional parameter is an enum.