How to get the current directory of the cmdlet being executed
Yes, that should work. But if you need to see the absolute path, this is all you need: (Get-Item .).FullName
Yes, that should work. But if you need to see the absolute path, this is all you need: (Get-Item .).FullName
Cmdlets themselves typically use no collection type in their output.[1]: They emit individual objects to the pipeline, which can situationally mean: zero, one, or multiple ones. This is precisely what Get-ADUser does: the specific number of output objects depends on the arguments that were given; that is why the Get-AdUser help topic only mentions scalar … Read more
In PSv3+, with its unified handling of scalars and collections, any object – even $null – should have a .Count property (and, with the exception of $null, should support indexing with [0]). Any occurrence of an object not supporting the above should be considered a bug; for instance: Using this intrinsic (engine-supplied) .Count property unexpectedly … Read more
# Delay-bind script-block argument: # The code inside { … } is executed for each input object ($_) and # the output is passed to the -NewName parameter. … | Rename-Item -NewName { $_.Name -replace ‘\.txt$’,’.log’ } The call above shows an application of a delay-bind script-block ({ … }) argument, which is an implicit … Read more