header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Viewing only unique extentions
Last Post 03 Jun 2008 09:38 PM by mhensley. 4 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
urielUser is Offline
New Member
New Member
Posts:2
Avatar

--
29 May 2008 02:56 PM  

I just started  learning powershell using Technet Virtual Labs

In this one lab the goal is to get all items in a directory then just view the extension object then  just list the unique extension so if a n extenstion exists 100 times the output will only show one

 

Here is the syntax:    get-childitem c:\windows\system | select-object extension | sort-object extension  -unique

The lab indicates that I am supposed to see all extenstions in the output, I am only seeing one file type


Extension
---------
.DRV

 

Does anyone have a clue as to why this is taking place ?

 

smurawskiUser is Offline
New Member
New Member
Posts:46

--
29 May 2008 03:08 PM  
Welcome to PowerShell!

I tried that command on my local system and was able to list out five distinct file extensions. I've also tried it on several other directories, with it listing out the proper extensions.

Were you trying this in the virtual lab or on your machine?
Steven Murawski
Co-Host - Mind of Root (www.mindofroot.com)
Host - PowerShell Basics (powershell-basics.com)
bsonposhUser is Offline
Basic Member
Basic Member
Posts:393
Avatar

--
29 May 2008 03:47 PM  
use system32 not system

also... I think group-object is a better solution here
get-childitem c:\windows\system32 | group-object extension
or
get-childitem c:\windows\system32 | group-object extension | %{$_.Name}
Brandon Shell
----------------
Microsoft Powershell MVP
https://mvp.support.microsoft.com/profile/Brandon
Blog: http://www.bsonposh.com
urielUser is Offline
New Member
New Member
Posts:2
Avatar

--
29 May 2008 04:47 PM  

I was running the lab on my own pc ....

I just realized that I had a typo at the end of the syntax ...  what is odd is that   power shell did not generate an error just odd results .. I retyped the command without a typo and it worked

 

 

mhensleyUser is Offline
New Member
New Member
Posts:14
Avatar

--
03 Jun 2008 09:38 PM  
For educational purposes, can you share the typo? It might be instructive to figure out what PowerShell thought you meant (i.e. why you didn't get an error message).
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer