Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 HALP! Questions on Windows and Windows Server
 PowerShell
 Powershell and "Flat" Folder/File Structures...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jadgate
Major Contributor

USA
918 Posts
Status: offline

Posted - 05/03/2012 :  11:27:37 AM  Show Profile  Reply with Quote
Or how to be a more efficient PS admin..

Don/Ed:

Enjoyed the presentations on PS at Minasi 2012 Conference and the message that if you want to stay a server admin, you've got to get off your duff and learn PS.

I'm not much of a server guy anymore, spend most of my days buried in excel spreadsheets and the like, but I had a thought about how the adoption of Powershell or the return to the command line in Windows server environments will impact how data is organized on Windows servers going forward (unless you enjoy spending your days typing really long ugly nested file paths into powershell commands)

Apologies if you covered this in your presentations during the conference and I missed it.

My question is this: how do you think best practice should/will develop for navigating around a system file and folder structure when we go back to the command line?

Right now, with the GUI, you can have a really ugly and deeply nested folder structure on say, a file server, which may involve many mouse clicks to get to the deeply nested folder and the data file it contains that you may want manipulate, but you can get there easily enough without a lot of typing. I recall enough from my early server admin days in the late 1990's that you would use cd.. to move around folder structure from the command line in DOS. My thinking is that if you have a really long nested folder structure on a file or data server, its gonna get really ugly to have to type all those path names (i.e. c:\folder1\subfolder1\subfolder2\subfolder3\subfolder4\datafile.txt.

Do you think that best practice will be to return to a more "flat" folder structure, where feasable, so you may have a lot of "folders" just below a logical partition like c: or are there other best practices like logical pointers or commands that will parse a folder and all sub-folders to manipulate data according to whatever parameters the command specifies?

Jim

James Adgate, CISSP
IT Auditor and Compliance Specialist
Data Loss Prevention (DLP)
IT Security Policy and Risk Mitigation for Enterprises
http://linkedin.com/in/jamesadgatech

Nobody
Here To Stay

USA
184 Posts
Status: offline

Posted - 05/03/2012 :  12:47:49 PM  Show Profile  Visit Nobody's Homepage  Reply with Quote
Two things come to mind, TAB TAB TAB TAB, and set paths in variables. Look at the help for get-childitem, lots of options for returning very specific results.

But to answer the question, while I generally try to avoid deeply nested folder structures, I wouldn't go changing anything.

We also use Powershell to work with Active Directory where you might have lengthy OU names, and also the registry, where we have basically no control of the structure.

aka - Matt
www.SnowTrek.org
Go to Top of Page

Perfect
Welcome Newcomer

3 Posts
Status: offline

Posted - 05/04/2012 :  11:36:28 AM  Show Profile  Reply with Quote
Maybe it is my infatuation with hotkeys/shortcuts or my personal distain for using a mouse at all but the long file paths are one of the major reasons why I like using Powershell, CMD, or even just Run. When creating automated process obviously using variables I only have to specify a path once, but even when opening a document or creating a directory in nested folders I prefer using Powershell.

In my particular environment my senior (I am somewhat a Powershell novice) recently created a function that calls specific file paths, data servers, exchange mailbox databases, proxy information, which is pulled from an .xml. As long as we keep that .xml up to date we’re able to quickly achieve a task that may otherwise require tons of clicking.

Sooner or later I’m hoping I can unplug my mouse altogether /CrossFingers

With that being said I also personally refrain from creating folder/files that are more than three or four layers in depth, and I encourage my users to do the same. I have ran across too many users that save their document using the ENTIRE first sentence of the document causing problems later down the road.

Brenton
Go to Top of Page

JeffWouters
Here To Stay

Netherlands
147 Posts
Status: offline

Posted - 05/05/2012 :  05:02:32 AM  Show Profile  Visit JeffWouters's Homepage  Click to see JeffWouters's MSN Messenger address  Look at the Skype address for JeffWouters  Reply with Quote
Using TAB always works fine for me... but a possible solution in some code (PowerShell v3):
$dir = Get-ChildItem -Directory -Recurse -filter "subfolder4"
cd $dir

or use the short version:
cd (Get-ChildItem -Directory -Recurse -filter "subdir4")

Now there are some downsides to this... first, I think that using TAB goes a heck of a lot faster... second, when there are multiple directories found with that name this command wouldn't be helpfull ;-)

Greetsz,
Jeff.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.09 seconds. Snitz Forums 2000