Ok in regards to Get-ChildItem/Copy-Item or any of these other generalized
cmdlets I'm really not frustrated. I just find them awkward to use for
"typical" file system maintance.
Your example on how to prevent a file from being silently overwritten is an
example. Yes it is a "one-liner" but so is CMD's
copy *.txt \archive
and "copy" will warn you if it's about to clobber a file.
Here is another example using Get-ChildItem; say I'd like to find all files
that have their archive and read-only bit set and order these by Creation
time and then by name. For CMDs "dir" its done this way
dir c:\junk /aar-d /o-dn /tc
however to do the same thing for GCI you need a longer line even if you do
use the shortcut aliases
gci "c:\junk" | % { $attr = $( $_.get_Attributes() ); if ( -not ( ( $attr
-bxor 33 ) -band 33 ) -and -not ( $attr -band 16 ) ) { $_} } | Sort
@{e={$_.CreationTime}; Descending=$true}, @{e={$_.Name}; Ascending=$true}
33 is ReadOnly | Achive and 16 is directory I used the values rather than
the constants to shorten up the line.
In both of these cases most people would prefer to use simpler, older method.
Lastly the "gratuitous" synthetic property that PowerShell provides. This I
definitely _do_ find frustrating.
It applies mostly when you're writting a script and and mis-spell a property
rather than get a parse error you suffer a runtime error because your logic
likely was expecting a value back of some sort. Here is a simple example
(dir).count
(dir).noexistantproperty
The second line returns $null rather than "property not found" which is what
the next example will do
(dir).noexistantproperty()
error method not found
Set-PSDebug -strict won't even help here. Unfortunately I don't think I'll
ever be able to program without a typo here or there. This is very
frustrating.
thx
bob
"Brandon Shell [MVP]" wrote:
Quote:
> While I agree... copy-item should have -noclobber switch.. it is easy to add
> with test-path
>
> Get-childitem | foreach{if(!(test-path $destination\$($_.Name)){copy-item $_
> $destination\$_.Name -verbose}}
>
> I dont understand the other things you dont like... I would like to know
> more. Do you think you could clarify your frustration?
>
> "Bob Landau" <BobLandau@xxxxxx> wrote in message
> news:87E163FE-2B8E-4C6D-A4BE-7D0E382ACCFA@xxxxxx Quote:
> > This is currently my biggest complaint about Powershell; with the
> > awkwardness
> > of using the Get-ChildItem cmdlet to query/sort for file properties being
> > 2nd; and Powershell's gratuitously providing you with _any_ non-existant
> > (of
> > your choice) Property which then will evaluate to NULL being the 3rd
> >
> > I have not found an equivalent to what you want Copy-Item -verbose will
> > merely tell you that you've overwritten a "precious" file _after_ the
> > fact.
> > -Confirm will ask you to validate the request regardless of whether there
> > is
> > a file to overwrite.
> >
> > Powershell has given us all the tools but for every day useage there needs
> > to be some additional functionalithy that provides us non-*nix's with the
> > safety and convience most of us are use to.
> >
> > "Marc Scheuner" wrote:
> > Quote:
> >> Folks,
> >>
> >> I really enjoy PowerShell, and its power - but sometimes, things are a
> >> bit irritating - like the fact that teh Copy-Item command doesn't seem
> >> to display messages about what it's doing at all. You never get any
> >> feedback printed on the standard out console to let you know that a
> >> file has indeed been copied.....
> >>
> >> Any way to turn that on?? I didn't find any mention of it in the "man
> >> pages" as far as I can tell.....
> >>
> >> Thanks!
> >> Marc
> >>
>