Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Victor
Jun 18, 2004
adaz, thanks for all the example scripts; may I steal them? Also, I would suggest adding Windows Powershell in Action &mdash it's a pretty good book written by someone from the inside.

I've written several PowerShell articles; here are a few that are probably more interesting:I kind of dove in intensely, got familiarized, wrote a bunch of articles (some of which are still very raw), and then moved on to other things.

Adbot
ADBOT LOVES YOU

Victor
Jun 18, 2004
You should know about Powershell Pipeline Performance. Other than that, Powershell's string escaping mechanism is not weird, and echo is no longer special.

Victor
Jun 18, 2004
Yes you can; you can use the System.Diagnostics.Proccess class, and/or P/Invoke. Do you need the Win32 APIs for doing what you want to do? (I would first check out the Process class to see how much you can do with that.)

Victor
Jun 18, 2004
Someone earlier in this thread said you have to Format-Table nothing or everything, but not half-and-half.

Victor
Jun 18, 2004
Walked: Tee-Object

Victor fucked around with this message at 00:14 on Oct 19, 2010

Victor
Jun 18, 2004
Walked, you might look for PowerShell equivalents for runas, or just use runas. (run as)

Victor
Jun 18, 2004
Ryouga Inverse, try this:
code:
(Get-Content input.prf) -replace "LOGIN", "BBQ" | Set-Content -Path new.prf
I'm not sure why there is no PoSH version of sed — the GnuWin32 version switches your documents to Unix-style \n line endings.

Your > new.prf may have caused a bunch of NULLs because it was trying to output Unicode; read up on $OutputEncoding.

Victor
Jun 18, 2004
Get-ChildItem -Recurse | ? { $_ -is [System.IO.DirectoryInfo] }

Victor
Jun 18, 2004
This should do ya:
code:
Get-ChildItem                              | 
    ? { $_ -is [System.IO.DirectoryInfo] } | 
    % { Get-ChildItem $_ }                 | 
    ? { $_ -is [System.IO.DirectoryInfo] }
(To those better at PowerShell, I'd love to know if there are better ways to do the above.)

Adbot
ADBOT LOVES YOU

Victor
Jun 18, 2004

marketingman posted:

Mate you are a lifesaver, that's done the trick nicely. If you have some time, would you mind explaining what each piece is doing, it seems like something I should have been able to quickly get my head around but for some reason haven't.
code:
Get-ChildItem                              | # get all items in the current directory
    ? { $_ -is [System.IO.DirectoryInfo] } | # filter to the ones that are directories
    % { Get-ChildItem $_ }                 | # get all items under each of those directories
    ? { $_ -is [System.IO.DirectoryInfo] }   # again, filter to all the items that are directories
Remember:
? is the same as Where-Object
% is the same as Foreach-Object

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply